auto2to3 makes it easier and faster to use
2to3 to develop for
Python 2 and 3 simultaneously. You can continue to work on the
original 2.x code, and
auto2to3 converts modules to Python 3
automatically at import time.
2to3 can be rather slow, so
caches its output between runs so it only needs to run
2to3 when the
source files change.
auto2to3 as usual using
easy_install. Note that
must be installed under Python 3 (it has only been tested with Python 3.2).
auto2to3 script supports a subset of the python interpreter's interface:
auto2to3 -m mypackage.main_module auto2to3 mypackage/script.py
By default, all modules imported from a subdirectory of the current
directory will be run through
2to3. To change this behavior, use the
--dir flags to
auto2to3 to specify which packages or
directories contain Python 2 code that should be converted.
auto2to3 is a development tool; when you're ready to release a
package that was developed with
auto2to3 you should use
setuptool's ability to run
2to3 as a part of the build process.
setup.py file, simply
import setuptools and pass
use_2to3=True as a keyword argument to the
Don't forget to remove or exclude
auto2to3's cache files from the
global-exclude _auto2to3* to
add a similar pattern to your
.gitignore or equivalent)
auto2to3.py by Georg Brandl: