Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use 2to3 tool in windows?

Tags:

I tried to modify the sintax using 2to3 tool by running command

python C:\Python32\Tools\scripts\2to3.py neo4j.py 

and got the output

enter image description here

When opening neo4j.py however I noticed there hasn't been anything changed. Below is the block of code where changes (accoridng to output) should be made:

try:     import json except ImportError:     import simplejson as json try:     from urllib.parse import quote except ImportError:     from urllib import quote try:     from . import rest, batch, cypher except ImportError:     import rest, batch, cypher except ValueError:     import rest, batch, cypher  import logging logger = logging.getLogger(__name__) 

Does anyone know how to use 2to3 tool properly in order to port/change the code to v3.2?

like image 994
Niko Gamulin Avatar asked Jun 17 '12 11:06

Niko Gamulin


People also ask

How do I run 2to3?

Running 2to3 is very simple. You give a file or directory as parameter and it will convert the file or look through the directory for Python files and convert them. 2to3 will print out all the changes to the output, but unless you include the -w flag it will not write the changes to the files.

What is 2to3?

2to3 is a Python program that reads Python 2. x source code and applies a series of fixers to transform it into valid Python 3. x code. The standard library contains a rich set of fixers that will handle almost all code.


1 Answers

You have to use the -w flag to actually write the changes:

python C:\Python32\Tools\scripts\2to3.py -w neo4j.py 

See the 2to3.py documentation.

like image 72
Simeon Visser Avatar answered Sep 24 '22 07:09

Simeon Visser