9 Oct
2008
9 Oct
'08
12:29 a.m.
On 10/7/08, Mark Hammond mhammond@skippinet.com.au wrote:
# This is a Python 3.x script to execute a python 2.x script by 2to3'ing it. import sys from lib2to3.refactor import RefactoringTool, get_fixers_from_package
fixers = get_fixers_from_package('lib2to3.fixes') options = dict(doctests_only=False, fix=[], list_fixes=[], print_function=False, verbose=False, write=True)
Note that only the print_function option is used.
r = RefactoringTool(fixers, options) script = sys.argv[1] data = open(script).read() print("Converting...") got = r.refactor_string(data, script) print("Executing...") # nuke ourselves from argv del sys.argv[1] exec(str(got))
python-committers mailing list python-committers@python.org http://mail.python.org/mailman/listinfo/python-committers
-- Cheers, Benjamin Peterson "There's nothing quite as beautiful as an oboe... except a chicken stuck in a vacuum cleaner."