You are here: Home Dive Into Python 3

Table of Contents

  1. What’s New In “Dive Into Python 3”
  2. Installing Python
    1. Diving In
    2. Which Python Is Right For You?
    3. Installing on Microsoft Windows
    4. Installing on Mac OS X
    5. Installing on Ubuntu Linux
    6. Installing on Other Platforms
    7. Using The Python Shell
    8. Python Editors and IDEs
  3. Your first Python program
    1. Diving in
    2. Declaring functions
    3. Writing readable code
      1. Docstrings
    4. The import search path
    5. Everything is an object
      1. What’s an object?
    6. Indenting code
    7. Exceptions
    8. Running scripts
    9. Further reading
  4. Native Python datatypes
    1. Diving in
    2. Booleans
    3. Numbers
      1. Coercing integers to floats and vice-versa
      2. Common numerical operations
      3. Fractions
      4. Trigonometry
      5. Numbers in a boolean context
    4. Lists
      1. Creating a list
      2. Slicing a list
      3. Adding items to a list
      4. Searching for values in a list
      5. Lists in a boolean context
    5. Tuples
      1. Assigning Multiple Values At Once
    6. Sets
      1. Creating A Set
      2. Modifying A Set
      3. Removing Items From A Set
      4. Common Set Operations
      5. Sets In A Boolean Context
    7. Dictionaries
      1. Creating a dictionary
      2. Modifying a dictionary
      3. Mixed-value dictionaries
      4. Dictionaries in a boolean context
    8. None
      1. None in a boolean context
    9. Further reading
  5. Comprehensions
    1. Diving In
    2. Working With Files And Directories
      1. The Current Working Directory
      2. Working With Filenames and Directory Names
      3. Listing Directories
      4. Getting File Metadata
      5. Constructing Absolute Pathnames
    3. List Comprehensions
    4. Dictionary Comprehensions
      1. Other Fun Stuff To Do With Dictionary Comprehensions
    5. Set Comprehensions
    6. Further Reading
  6. Strings
    1. Some Boring Stuff You Need To Understand Before You Can Dive In
    2. Unicode
    3. Diving In
    4. Formatting Strings
      1. Compound Field Names
      2. Format Specifiers
    5. Other Common String Methods
      1. Slicing A String
    6. Strings vs. Bytes
    7. Postscript: Character Encoding Of Python Source Code
    8. Further Reading
  7. Regular expressions
    1. Diving in
    2. Case study: street addresses
    3. Case study: Roman numerals
      1. Checking for thousands
      2. Checking for hundreds
    4. Using the {n,m} Syntax
      1. Checking for tens and ones
    5. Verbose regular expressions
    6. Case study: parsing phone numbers
    7. Summary
  8. Closures & Generators
    1. Diving in
    2. I know, let’s use regular expressions!
    3. A list of functions
    4. A list of patterns
    5. A file of patterns
    6. Generators
      1. A Fibonacci generator
      2. A plural rule generator
  9. Classes & Iterators
    1. Diving In
    2. Defining Classes
    3. Instantiating Classes
    4. Instance Variables
    5. A Fibonacci iterator
    6. A Plural Rule Iterator
    7. Further Reading
  10. Advanced Iterators
    1. Diving In
    2. Finding all occurrences of a pattern
    3. Finding the unique items in a sequence
    4. Making assertions
    5. Generator expressions
    6. Calculating Permutations… The Lazy Way!
    7. Other Fun Stuff in the itertools Module
    8. A New Kind Of String Manipulation
    9. Evaluating Arbitrary Strings As Python Expressions
    10. Putting It All Together
    11. Further Reading
  11. Unit Testing
    1. (Not) Diving In
    2. A single Question
    3. “Halt and Catch Fire”
    4. More Halting, More Fire
    5. And One More Thing…
    6. A Pleasing Symmetry
    7. More Bad Input
  12. Refactoring
    1. Diving in
    2. Handling Changing Requirements
    3. Refactoring
    4. Summary
  13. Files
    1. Diving In
    2. Reading From Text Files
      1. Character Encoding Rears Its Ugly Head
      2. File Objects
      3. Reading Data From A Text File
      4. Closing Files
      5. Closing Files Automatically
      6. Reading Data One Line At A Time
    3. Writing to Text Files
      1. Character Encoding Again
    4. Binary Files
    5. File-like Objects
      1. Handling Compressed Files
    6. Standard Input, Output, and Error
      1. Redirecting Standard Output
    7. Further Reading
  14. XML
    1. Diving In
    2. A 5-Minute Crash Course in XML
    3. The Structure Of An Atom Feed
    4. Parsing XML
      1. Elements Are Lists
      2. Attributes Are Dictonaries
    5. Searching For Nodes Within An XML Document
    6. Going Further With lxml
      1. Customizing Your XML Parser
      2. Incremental Parsing
    7. Generating XML
    8. Further Reading
  15. Serializing Python Objects
    1. ...diving in...
  16. HTTP Web Services
    1. Diving In
    2. Features of HTTP
      1. Caching
      2. Last-Modified Checking
      3. ETags
      4. Compression
      5. Redirects
    3. How Not To Fetch Data Over HTTP
    4. What’s On The Wire?
    5. Introducing httplib2
      1. How httplib2 Handles Caching
      2. How httplib2 Handles Last-Modified and ETag Headers
      3. How http2lib Handles Compression
      4. How httplib2 Handles Redirects
    6. Beyond HTTP GET
    7. Beyond HTTP POST
    8. Further Reading
  17. Threading & Multiprocessing
    1. ...
  18. Case study: porting chardet to Python 3
    1. Introducing chardet: a mini-FAQ
      1. What is character encoding auto-detection?
      2. Isn’t that impossible?
      3. Who wrote this detection algorithm?
      4. Yippie! Screw the standards, I’ll just auto-detect everything!
      5. Why bother with auto-detection if it’s slow, inaccurate, and non-standard?
    2. Diving in
      1. UTF-n with a BOM
      2. Escaped encodings
      3. Multi-byte encodings
      4. Single-byte encodings
      5. windows-1252
    3. Running 2to3
    4. Fixing what 2to3 can’t
      1. False is invalid syntax
      2. No module named constants
      3. Name 'file' is not defined
      4. Can’t use a string pattern on a bytes-like object
      5. Can’t convert 'bytes' object to str implicitly
  19. Packaging Python libraries
    1. ...
  20. Where to go from here
    1. Things to read
    2. Where to look for Python 3-compatible code

© 2001–9 Mark Pilgrim