Skip to main content

Automated Python 2 to 3 code translation.

# To display changes that would be performed:
2to3 <path/to/file.py>

# To convert a Python 2 file to Python 3:
2to3 --write <path/to/file.py>

# To convert a specified Python 2 feature to Python 3:
2to3 --write <file.py> --fix=<raw_input> --fix=<print>

# To convert all features except *raw_input* the specified ones to Python 3:
2to3 --nofix=<raw_input> --fix=<print> example.py

# To display the list of available transformation features:
2to3 --list-fixes

# To convert an entire directory:
2to3 --output-dir=<path/to/code_python3_version> --write-unchanged-files --nobackups <path/to/code_python2_version>