已读100%
预计阅读本页时间:-
预计阅读本页时间:-
Document Outline
广告:个人专属 VPN,独立 IP,无限流量,多机房切换,还可以屏蔽广告和恶意软件,每月最低仅 5 美元
- What’s New In “Dive Into Python 3”
- Installing Python
- Your First Python Program
- Native Datatypes
- Comprehensions
- Strings
- Regular Expressions
- Closures & Generators
- Classes & Iterators
- 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
- Refactoring
- Files
- XML
- Serializing Python Objects
- Diving In
- Saving Data to a Pickle File
- Loading Data from a Pickle File
- Pickling Without a File
- Bytes and Strings Rear Their Ugly Heads Again
- Debugging Pickle Files
- Serializing Python Objects to be Read by Other Languages
- Saving Data to a JSON File
- Mapping of Python Datatypes to JSON
- Serializing Datatypes Unsupported by JSON
- Loading Data from a JSON File
- Further Reading
- HTTP Web Services
- Case Study: Porting chardet to Python 3
- Diving In
- What is Character Encoding Auto-Detection?
- Introducing The chardet Module
- Running 2to3
- A Short Digression Into Multi-File Modules
- 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
- Unsupported operand type(s) for +: 'int' and 'bytes'
- ord() expected string of length 1, but int found
- Unorderable types: int() >= str()
- Global name 'reduce' is not defined
- Summary
- Packaging Python Libraries
- Diving In
- Things Distutils Can’t Do For You
- Directory Structure
- Writing Your Setup Script
- Classifying Your Package
- Specifying Additional Files With A Manifest
- Checking Your Setup Script for Errors
- Creating a Source Distribution
- Creating a Graphical Installer
- Adding Your Software to The Python Package Index
- The Many Possible Futures of Python Packaging
- Further Reading
- Porting Code to Python 3 with 2to3
- Diving In
- print statement
- Unicode string literals
- unicode() global function
- long data type
- <> comparison
- has_key() dictionary method
- Dictionary methods that return lists
- Modules that have been renamed or reorganized
- Relative imports within a package
- next() iterator method
- filter() global function
- map() global function
- reduce() global function
- apply() global function
- intern() global function
- exec statement
- execfile statement
- repr literals (backticks)
- try...except statement
- raise statement
- throw method on generators
- xrange() global function
- raw_input() and input() global functions
- func_* function attributes
- xreadlines() I/O method
- lambda functions that take a tuple instead of multiple parameters
- Special method attributes
- __nonzero__ special method
- Octal literals
- sys.maxint
- callable() global function
- zip() global function
- StandardError exception
- types module constants
- isinstance() global function
- basestring datatype
- itertools module
- sys.exc_type, sys.exc_value, sys.exc_traceback
- List comprehensions over tuples
- os.getcwdu() function
- Metaclasses
- Matters of style
- Special Method Names
- Diving In
- Basics
- Classes That Act Like Iterators
- Computed Attributes
- Classes That Act Like Functions
- Classes That Act Like Sets
- Classes That Act Like Dictionaries
- Classes That Act Like Numbers
- Classes That Can Be Compared
- Classes That Can Be Serialized
- Classes That Can Be Used in a with Block
- Really Esoteric Stuff
- Further Reading
- Where To Go From Here
- Troubleshooting