标签:
关于本书
关于术语
序
欢迎来到Python 3
是时候了吗?
如果我现在不能切换会怎么样?
Python 和它的版本
更多资源
迁移策略
仅支持Python 3
Python 2和Python 3的单独分支
使用2to3转换到Python 3
使用Distribute来支持2to3转换
无需转换支持Python 2 和 Python 3
使用3to2
哪种策略适合你?
应用
Python模块和包
框架
结论
Preparing for Python 3
Comparatively tricky
Implementing __hash__()
Run under Python 2.7.
Use // instead of / when dividing integers
Use new-style classes
Separate binary data and strings
When sorting, use key instead of cmp
Use rich comparison operators
Make sure you aren’t using any removed modules
Testing coverage and tox
Optional: Use the iterator-methods on dictionaries
2to3
Running tests with Distribute
Running 2to3 with Distribute
Running 2to3 on install
Explicit fixers
Using 2to3
Distributing packages
Supporting multiple versions of Python with Distribute
Common migration problems
write() has a return value
Types are now classes
Handling expected exceptions
String representation
dict and set order
Byte literals
Binary data in Python 2 and Python 3
Nicer solutions
Manipulating binary data
Reading from files
Incorrect imports
Relative import problems
Unorderable types, __cmp__ and cmp
Sorting
Sorting Unicode
Bytes, strings and Unicode
Replacing UserDict
CSV API changes
Running doctests
Improving your code with modern idioms
Abstract base classes
multiprocessing and futures
numbers and fractions
Use sorted() instead of .sort()
Coding with context managers
Advanced string formatting
Class decorators
Set literals
yield to the generators
More comprehensions
The next next()
New modules
Supporting Python 2 and 3 without 2to3 conversion
Supporting the print() function
Handling exceptions
Import errors
Integer incompatibilities
More bytes, strings and Unicode
Two times three is “six”
Migrating C extensions
Before you start
Object initialization
Module initialization
Changes in Python
Strings and Unicode
Extending 2to3 with your own fixers
When fixers are necessary
The Parse Tree
Creating a fixer
Modifying the Parse Tree
Finding the nodes with Patterns
Language differences and workarounds
apply()
buffer()
callable()
Classes
Comparisons
coerce() and __coerce__
Dictionary methods
except
Exception objects
exec
execfile
file
filter()
Imports
Indentation
input() and raw_input()
Integer division
long
map()
Metaclasses
.next()
Parameter unpacking
print
raise
range() and xrange()
repr() as backticks.
Rounding behavior
Slice operator methods
StandardError
String types
Reorganizations and renamings
urllib, urllib2 and urlparse
The standard library
Removed modules
Moved builtins
string module removals
Function and method attribute renamings
Supporting Python 3(支持Python 3)——目录
原文地址:http://my.oschina.net/soarwilldo/blog/508412