I am able to load the 2to3
file in Terminal. It does a lot of printing, with output like the following:
- print str
+ print(str) ...
But the file is left without changes. And I don’t have any instructions after “run 2to3
”. Please help.
I am able to load the 2to3
file in Terminal. It does a lot of printing, with output like the following:
- print str
+ print(str) ...
But the file is left without changes. And I don’t have any instructions after “run 2to3
”. Please help.
If you search for “2to3” the first result is the documentation for 2to3. As the documentation says, to overwrite the file instead of printing a diff, you just need to add the -w
flag:
[When you run the following:]
$ 2to3 example.py
A diff against the original source file is printed. 2to3 can also write the needed modifications right back to the source file. (A backup of the original file is made unless
-n
is also given.) Writing the changes back is enabled with the-w
flag:$ 2to3 -w example.py