Python Pocket Reference, 4th Edition

Book description

This is the book to reach for when you're coding on the fly and need an answer now. It's an easy-to-use reference to the core language, with descriptions of commonly used modules and toolkits, and a guide to recent changes, new features, and upgraded built-ins -- all updated to cover Python 3.X as well as version 2.6. You'll also quickly find exactly what you need with the handy index.

Written by Mark Lutz -- widely recognized as the world's leading Python trainer -- Python Pocket Reference, Fourth Edition, is the perfect companion to O'Reilly's classic Python tutorials, also written by Mark: Learning Python and Programming Python.

  • Built-in object types, including numbers, lists, dictionaries, and more
  • Statements and syntax for creating and processing objects
  • Functions and modules for structuring and reusing code
  • Python's object-oriented programming tools
  • The exception-handling model
  • Built-in functions, exceptions, and attributes
  • Special operator overloading methods
  • Widely used standard library modules and extensions
  • Command-line options and development tools
  • Python idioms and hints

Publisher resources

View/Submit Errata

Table of contents

  1. Python Pocket Reference
  2. 1. Python Pocket Reference
    1. Introduction
    2. Conventions
    3. Using Code Examples
    4. Safari® Books Online
    5. Command-Line Options
      1. Python Options
      2. Program Specification
    6. Environment Variables
      1. Operational Variables
      2. Command-Line Option Variables
    7. Built-in Types and Operators
      1. Operators and Precedence
      2. Operator Usage Notes
      3. Operations by Category
      4. Sequence Operation Notes
        1. Indexing: S[i]
        2. Slicing: S[i:j]
        3. Slicing: S[i:j:k]
        4. Other
    8. Specific Built-in Types
      1. Numbers
        1. Literals and creation
        2. Operations
        3. Decimal and fraction
        4. Other numeric types
      2. Strings
        1. Literals and creation
        2. Operations
        3. String formatting
        4. String formatting expression
        5. String formatting method
        6. Template string substitution
        7. String methods
        8. byte and bytearray methods
        9. Searching
        10. Splitting and joining
        11. Formatting
        12. Content tests
        13. The original string module
      3. Unicode Strings
        1. Unicode support in Python 3.0
        2. byte and bytearray strings
        3. Unicode support in Python 2.X
      4. Lists
        1. Literals and creation
        2. Operations
        3. List comprehension expressions
        4. Generator expressions
        5. Other generators and comprehensions
      5. Dictionaries
        1. Literals and creation
        2. Operations
      6. Tuples
        1. Literals
        2. Operations
      7. Files
        1. Input files
        2. Output files
        3. Any files
        4. Attributes (all read-only)
        5. File context managers
        6. Notes
      8. Sets
        1. Literals and creation
        2. Operations
      9. Other Common Types
        1. Boolean
      10. Type Conversions
    9. Statements and Syntax
      1. Syntax Rules
      2. Name Rules
        1. Name format
        2. Name conventions
    10. Specific Statements
      1. The Assignment Statement
        1. Augmented assignment
        2. Normal and extended sequence assignment
      2. The Expression Statement
        1. Call syntax
        2. Arbitrary arguments call syntax
      3. The print Statement
        1. Python 2.X print statements
      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 def Statement
        1. Python 3.0 keyword-only arguments
        2. Python 3.0 function annotations
        3. lambda expressions
        4. Defaults and attributes
        5. Function and method decorators
      12. The return Statement
      13. The yield Statement
        1. Generators and iterators
      14. The global Statement
      15. The nonlocal Statement
      16. The import Statement
        1. Package imports
      17. The from Statement
        1. Package relative import syntax
      18. The class Statement
        1. Class decorators in Python 2.6 and 3.0
        2. Metaclasses
      19. The try Statement
        1. Python 2.X try statement forms
      20. The raise Statement
        1. Class exceptions
        2. Python 2.X raise statement forms
      21. The assert Statement
      22. The with Statement
        1. Multiple context managers in Python 3.1
      23. Python 2.X Statements
    11. Namespace and Scope Rules
      1. Qualified Names: Object Namespaces
      2. Unqualified Names: Lexical Scopes
      3. Statically Nested Scopes
    12. Object-Oriented Programming
      1. Classes and Instances
        1. Class objects provide default behavior
        2. Instance objects are generated from classes
        3. Inheritance rules
      2. Pseudoprivate Attributes
        1. Module privates
        2. Class privates
      3. New Style Classes
    13. Operator Overloading Methods
      1. For All Types
      2. For Collections (Sequences, Mappings)
      3. For Numbers (Binary Operators)
        1. Basic binary methods
        2. Right-side binary methods
        3. Augmented binary methods
      4. For Numbers (Other Operations)
      5. For Descriptors
      6. For Context Managers
      7. Python 2.X Operator Overloading Methods
        1. Methods in Python 3.0 only
        2. Methods in Python 2.X only
    14. Built-in Functions
      1. Python 2.X Built-in Functions
        1. Python 3.0 built-ins not supported by Python 2.6
        2. Python 2.6 built-ins not supported by Python 3.0
    15. Built-in Exceptions
      1. Superclasses (Categories)
      2. Specific Exceptions Raised
      3. Warning Category Exceptions
      4. Warnings Framework
      5. Python 2.X Built-in Exceptions
    16. Built-in Attributes
    17. Standard Library Modules
    18. The sys Module
    19. The string Module
      1. Module Functions and Classes
      2. Constants
    20. The os System Module
      1. Administrative Tools
      2. Portability Constants
      3. Shell Commands
      4. Environment Tools
      5. File Descriptor Tools
      6. File Pathname Tools
      7. Process Control
      8. The os.path Module
    21. The re Pattern-Matching Module
      1. Module Functions
      2. Regular Expression Objects
      3. Match Objects
      4. Pattern Syntax
    22. Object Persistence Modules
      1. dbm and shelve Modules
      2. pickle Module
        1. Pickling interfaces
        2. Unpickling interfaces
        3. Usage notes
    23. The tkinter GUI Module and Tools
      1. tkinter Example
      2. tkinter Core Widgets
      3. Common Dialog Calls
        1. Module tkinter.messagebox (tkMessageBox in Python 2.X)
        2. Module tkinter.simpledialog (tkSimpleDialog in Python 2.X)
        3. Module tkinter.colorchooser (tkColorChooser in Python 2.X)
        4. Module tkinter.filedialog (tkFileDialog in Python 2.X)
      4. Additional tkinter Classes and Tools
      5. Tcl/Tk-to-Python/tkinter Mappings
    24. Internet Modules and Tools
      1. Commonly Used Library Modules
    25. Other Standard Library Modules
      1. The math Module
      2. The time Module
      3. The datetime Module
      4. Threading Modules
      5. Binary Data Parsing
    26. Python Portable SQL Database API
      1. API Usage Example
      2. Module Interface
      3. Connection Objects
      4. Cursor Objects
      5. Type Objects and Constructors
    27. Python Idioms and Hints
      1. Core Language Hints
      2. Environment Hints
      3. Usage Hints
      4. Assorted Hints
  3. Index
  4. About the Author
  5. Copyright

Product information

  • Title: Python Pocket Reference, 4th Edition
  • Author(s): Mark Lutz
  • Release date: October 2009
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781449379339