I'm given a task of converting a bunch of codes written in Python 2.7 into Python 3. So my question is What are the fundamental differences between the two and what are the new features expected from conversion? I'm assuming it's not just syntactical issues. Where should I start and what should I focus on? It'll be more helpful if you could be as concrete as possible.. Please help me out and thank you in advance
3 Answers
Definitely start here: http://docs.python.org/py3k/whatsnew/3.0.html
For an automated tool, see: http://docs.python.org/library/2to3.html
3 Comments
CosmicRabbitMediaInc
I know this is a dumb question, but how do you actually install it? I can't seem to find the download link..
CosmicRabbitMediaInc
I found svn.python.org/projects/sandbox/trunk/2to3 but don't know what to do with the files to install it...
Greg Hewgill
2to3 should be already installed with your Python. If you can type python from a prompt and have it run, then you should also be able to run 2to3 the same way.Building from Greg's answer I find find it easier to grok the changes by looking at different compatibility layers people have built in order to support 2 and 3 in parallel.
- CherryPy, or specifically this file.
- Six, or specifically this file.
- Pyramid, or specifically this file.
To use a compatibility layer or not is a widely discussed topic, however they are a good programmatic reference too scope the major changes and what you need to do in order to support them.