You are previewing Python Pocket Reference.
O'Reilly logo
Python Pocket Reference

Book Description

Python is a popular object-oriented scripting language that is freely available over the Net. It's portable, powerful, and remarkably easy to use. Python is commonly used for both stand-alone programs and scripting applications, in a wide variety of domains. This book is a companion volume to two O'Reilly Animal Guides, Programming Python and Learning Python. It summarizes Python statements and types, built-in functions, commonly used library modules, and other prominent Python language features. This pocket reference covers the latest Python release and complements Python's online reference material.

Table of Contents

  1. Python Pocket Reference
    1. 1. Python Pocket Reference
      1. Introduction
      2. Conventions
      3. Command-Line Options
      4. Environment Variables
      5. Built-in Types and Operators
        1. Operators and Precedence
        2. Operations by Category
        3. Sequence Operation Notes
          1. Indexing: S[i]
          2. Slicing: S[i:j ]
          3. Other
        4. Specific Built-in Types
          1. Numbers
            1. Constants
            2. Operations
          2. Strings
            1. Constants
            2. Operations
          3. Lists
            1. Constants
            2. Operations
          4. Dictionaries
            1. Constants
            2. Operations
          5. Tuples
            1. Constants
            2. Operations
          6. Files
            1. Input Files
            2. Output Files
            3. Any Files
        5. Type Conversions
      6. Statements and Syntax
        1. Syntax Rules
        2. Name Rules
        3. Specific Statements
          1. Assignment
          2. Expressions
          3. The print Statement
          4. The if Statement
          5. The while Statement
          6. The for Statement
          7. The pass Statement
          8. The break Statement
          9. The continue Statement
          10. The del Statement
          11. The exec Statement
          12. The def Statement
          13. The return Statement
          14. The global Statement
          15. The import Statement
          16. The from Statement
          17. The class Statement
          18. The try Statement
          19. The raise Statement
          20. The assert Statement
      7. Namespace and Scope Rules
        1. Unqualified Names: Global Unless Assigned
        2. Qualified Names: Object Namespaces
      8. Object-Oriented Programming
        1. Classes and Instances
          1. Class Objects Provide Default Behavior
          2. Instance Objects Are Generated from Classes
          3. Inheritance Rules
        2. Special Overloading Methods
          1. For All Types
          2. For Collections (Sequences, Mappings)
          3. For Numbers (Binary)
          4. For Numbers (Other)
        3. Private Attributes
      9. Built-in Functions
      10. Built-in Exceptions
        1. Base Classes (Categories)
        2. Specific Exceptions
      11. Built-in Attributes
      12. Major Built-in Modules
        1. The sys Module
        2. The string Module
          1. Constants
          2. Functions
          3. Conversions
          4. Searching
          5. Splitting and joining
          6. Formatting
        3. The os Module
        4. The posix Module
          1. Files and Directories
          2. Processes
          3. Environment
        5. The posixpath Module
        6. The math Module
        7. The time Module
        8. The re Module
          1. Regular Expression Objects
          2. Match Objects
        9. The regex Module
      13. Other Built-in Modules
      14. Persistence: dbm, shelve, pickle
        1. dbm and shelve Interfaces
        2. Pickle Interface
      15. Debugger and Profiler
        1. The Debugger
          1. Top-Level Interface
          2. Interactive Commands
        2. The Profiler
          1. Top-level Interface
      16. Python Mode for Emacs
        1. Indentation
        2. Processing Regions of Code
        3. Moving the Point
        4. Executing Python Code
        5. Variables
      17. Python Idioms and Hints