Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert Python 2.x series to Python 3.x series
08-07-2010, 11:31 PM
Post: #1
Convert Python 2.x series to Python 3.x series
Python 3 comes with a program called 2to3. This program allows you to convert your Python 2.x scripts to 3.x scripts. I convert all my scripts to 3.1 so I can run with on either 2.x or 3.x series. Examples of using 2to3 on mac or Linux.

Code:
2to3 myscript.py //This will print all the that 2to3 will change in a script without physically chaning it

2to3 -w myscript.py //This will actually write the changes to the file but also make a backup of the first script.

There are other commands you can do using 2to3 just type 2to3 --help to see a list of commands.
Find all posts by this user
Quote this message in a reply
09-27-2010, 12:26 AM
Post: #2
RE: Convert Python 2.x series to Python 3.x series
What are the major differences? I know that the print statement now requires parentheses and raw_input has been replaced by just input.

"Character is determined more by the lack of certain experiences than by those one has had."
Friedrich Nietzsche
Visit this user's website Find all posts by this user
Quote this message in a reply
07-11-2011, 06:22 PM
Post: #3
RE: Convert Python 2.x series to Python 3.x series
Yea, must be closed in () and some minor function change in math classes etc... Instead of returning a integer it may return a float. Not to many major changes though.
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


 Quick Theme: