1

When I run 2to3.py -w my_script.py it converts my_script.py to Python3 and then puts the original version my_script.py.bak.

I want the old file to remain as is, and the converted file to go into a new file, like my_script.converted.py. Is there a 2to3.py argument that allows this?

Superbest
  • 25,318
  • 14
  • 62
  • 134

1 Answers1

1

Turns out there's several options for this:

  • Copy the file first to a new location, then run 2to3 -w -n which modifies the file in place (-w) without making a backup (-n)
  • 2to3 -n -o desired/path/to/new/file specifies an output directory (-o) and disables backup (-n)
  • 2to3 -n -W --add-suffix=3 will put the file in the same location, but put a suffix on it (-W --add-suffix=) without making a backup (n)
Superbest
  • 25,318
  • 14
  • 62
  • 134