Supporting Python 3¶
- About this book
- Foreword
- Welcome to Python 3
- Migration strategies
- Preparing for Python 3
- 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
- Common migration problems
- Improving your code with modern idioms
- Supporting Python 2 and 3 without 2to3 conversion
- Migrating C extensions
- Extending 2to3 with your own fixers
- 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
- raise
- range() and xrange()
- repr() as backticks.
- Rounding behavior
- Slice operator methods
- Sorting
- StandardError
- String types
- Reorganizations and renamings