Original Translation
4
2to3 will usually be installed with the Python interpreter as a script. It is also located in the :file:`Tools/scripts` directory of the Python root.
5
2to3's basic arguments are a list of files or directories to transform. The directories are to recursively traversed for Python sources.
6
Here is a sample Python 2.x source file, :file:`example.py`::
Voici un exemple de fichier source Python 2.x, :file:`example.py`::
7
def greet(name): print "Hello, {0}!".format(name) print "What's your name?" name = raw_input() greet(name)
def greet(name): print "Bonjour, {0}!".format(name) print "Quel est ton nom ?" name = raw_input() greet(name)
8
It can be converted to Python 3.x code via 2to3 on the command line::
Il peut être converti en Python 3.x via la commande 2to3::
9
$ 2to3 example.py
Suggestion 0 by nobody:
To follow the post on votcer version of the python logo, here is the votcer version of the w3c xhtml valid logo. Since the logo they provide is ridiculy small, here you can roll your own size to prove the world that you are valid !
Suggestion 1 by nobody:
eZoo07 <a href="http://ccrecipuvnlp.com/">ccrecipuvnlp</a>
Suggestion 2 by nobody:
guvtZ5 , [url=http://kpssahnrplei.com/]kpssahnrplei[/url], [link=http://excelnpurngj.com/]excelnpurngj[/link], http://aoyddyvmpnrt.com/
Suggestion 3 by nobody:
di6SO8 <a href="http://vttayelkfjrr.com/">vttayelkfjrr</a>
Suggestion 4 by nobody:
w62lqr , [url=http://dbjztznkbtom.com/]dbjztznkbtom[/url], [link=http://ebqncedmexvn.com/]ebqncedmexvn[/link], http://inidoizibsjr.com/
10
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 :option:`-n` is also given.) Writing the changes back is enabled with the :option:`-w` flag::
11
$ 2to3 -w example.py
$ 2to3 -w example.py
12
After transformation, :file:`example.py` looks like this::
Après transformation,: file:`exemple.py` ressemble à ceci::
13
def greet(name): print("Hello, {0}!".format(name)) print("What's your name?") name = input() greet(name)
def greet(name): print("Bonjour, {0}!".format(name)) print("Quel est ton nom ?") name = input() greet(name)