You are here: Home ‣ Dive Into Python 3 ‣
Table of Contents
- What’s New In “Dive Into Python 3”
- Installing Python
- Diving In
- Which Python Is Right For You?
- Installing on Microsoft Windows
- Installing on Mac OS X
- Installing on Ubuntu Linux
- Installing on Other Platforms
- Using The Python Shell
- Python Editors and IDEs
- Your first Python program
- Diving in
- Declaring functions
- Writing readable code
- Docstrings
- Everything is an object
- The
import search path
- What’s an object?
- Indenting code
- Exceptions
- Running scripts
- Further reading
- Native Python datatypes
- Diving in
- Booleans
- Numbers
- Coercing integers to floats and vice-versa
- Common numerical operations
- Fractions
- Trigonometry
- Numbers in a boolean context
- Lists
- Creating a list
- Slicing a list
- Adding items to a list
- Searching for values in a list
- Lists in a boolean context
- Dictionaries
- Creating a dictionary
- Modifying a dictionary
- Mixed-value dictionaries
- Dictionaries in a boolean context
None
None in a boolean context
- Further reading
- Strings
- Diving in
- Unicode
- How strings are stored in memory
- Converting between different character encodings
- Specifying character encoding in
.py files
- Strings in Python 3
- Common string operations
- Formatting strings
- The
string module
- Strings vs. bytes
- Further reading
- Regular expressions
- Diving in
- Case study: street addresses
- Case study: Roman numerals
- Checking for thousands
- Checking for hundreds
- Using the
{n,m} Syntax
- Checking for tens and ones
- Verbose regular expressions
- Case study: parsing phone numbers
- Summary
- Closures & Generators
- Diving in
- I know, let’s use regular expressions!
- A list of functions
- A list of patterns
- A file of patterns
- Generators
- A Fibonacci generator
- A plural rule generator
- Classes & Iterators
- Diving In
- Defining Classes
- Instantiating Classes
- Instance Variables
- A Fibonacci iterator
- A Plural Rule Iterator
- Further Reading
- Advanced Iterators
- Diving In
- Finding all occurrences of a pattern
- Finding the unique items in a sequence
- Making assertions
- Generator expressions
- Calculating Permutations… The Lazy Way!
- Other Fun Stuff in the
itertools Module
- A New Kind Of String Manipulation
- Evaluating Arbitrary Strings As Python Expressions
- Putting It All Together
- Further Reading
- Unit testing
- (Not) diving in
- A single question
- “Halt and catch fire”
- More halting, more fire
- ...
- Advanced Unit Testing
- ...
- Refactoring your code
- Diving in
- Handling changing requirements
- Refactoring
- Summary
- Advanced Classes
- Diving in
- Files
- File objects
- Reading files
- Close your files... or don't
- Handling errors (exceptions)
- Writing to files
- XML
- Diving In
- A 5-Minute Crash Course in XML
- The Structure Of An Atom Feed
- Parsing XML
- Elements Are Lists
- Attributes Are Dictonaries
- Searching For Nodes Within An XML Document
- Going Further With lxml
- Customizing Your XML Parser
- Incremental Parsing
- Generating XML
- Further Reading
- Serializing Python Objects
- HTTP Web Services
- Diving In
- Features of HTTP
- Caching
- Last-Modified Checking
- ETags
- Compression
- Redirects
- How Not To Fetch Data Over HTTP
- What’s On The Wire?
- Introducing
httplib2
- How
httplib2 Handles Caching
- How
httplib2 Handles Last-Modified and ETag Headers
- How
http2lib Handles Compression
- How
httplib2 Handles Redirects
- Beyond HTTP GET
- Beyond HTTP POST
- Further Reading
- Threading & Multiprocessing
- Packaging Python libraries
- A brief history of packaging (and why it's harder than you think)
- setuptools
- distutils
- Eggs
- pip
- Platform-specific packaging
- Packaging by Linux distributions
- Py2exe
- Case study: porting
chardet to Python 3
- Introducing
chardet: a mini-FAQ
- What is character encoding auto-detection?
- Isn’t that impossible?
- Who wrote this detection algorithm?
- Yippie! Screw the standards, I’ll just auto-detect everything!
- Why bother with auto-detection if it’s slow, inaccurate, and non-standard?
- Diving in
UTF-n with a BOM
- Escaped encodings
- Multi-byte encodings
- Single-byte encodings
windows-1252
- Running
2to3
- Fixing what
2to3 can’t
False is invalid syntax
- No module named
constants
- Name 'file' is not defined
- Can’t use a string pattern on a bytes-like object
- Can’t convert '
bytes' object to str implicitly
- Where to go from here
- Things to read
- Where to look for Python 3-compatible code
Orphans (not sure where these belong yet):
- Tuples
- List comprehensions
- Set comprehensions
- Dictionary comprehensions
- Views (several dictionary methods return them, they're dynamic, update when the dictionary changes, etc.)
- Function annotations
- PEP 8 style conventions
- Decorators
@unittest.skipUnless(sys.platform.startswith("win"), "requires Windows")
- Importing modules
- ...mention why from module import * is only allowed at module level
© 2001–9 Mark Pilgrim