Table of Contents
- 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’tFalse
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 tostr
implicitly - Unsupported operand type(s) for +:
‘int‘
and‘bytes‘
ord()
expected string of length 1, butint
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 functionlong
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 methodfilter()
global functionmap()
global functionreduce()
global functionapply()
global functionintern()
global functionexec
statementexecfile
statementrepr
literals (backticks)try...except
statementraise
statementthrow
method on generatorsxrange()
global functionraw_input()
andinput()
global functionsfunc_*
function attributesxreadlines()
I/O methodlambda
functions that take a tuple instead of multiple parameters- Special method attributes
__nonzero__
special method- Octal literals
sys.maxint
callable()
global functionzip()
global functionStandardError
exceptiontypes
module constantsisinstance()
global functionbasestring
datatypeitertools
modulesys.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
参考:http://www.diveintopython3.net/
时间: 2024-10-15 08:18:10