I'm new to programming and thought Python would be a good language to learn. Most of the tutorials I found were 2.7 based so I started to learn using that version. I've recently found a tkinter tutorial that I'd like to try out but I'm having a problem. If I run a script it will use Python 2.7 which contains Tkinter and not tkinter.
This problem made me think, how can I get my two versions to co-exist so I can program in both 2.x and 3.x?
It depends on what you are trying to do. You can have them coexist because 3.2 is backwards-compatible. Now you can install both versions on your computer 3.2 and 2.7, but 3.2 unfortunately will have to be used in IDLE....ugh.... Just install both and then depending on which one you want to use. Run that IDLE for either one or the other.
Now if you are meaning that you want more stable version that can be professionally done, go with 2.7 ( I have done otherwise, but if you run into problems 2.7 is more supported.
If you want the more cutting edge stuff, go with 3.2. Either one you go with works with about eveyrthing. If it doesn't, give it a month or two and the rest of the world will catch up.
There is limited support for some of the Python 3 functionality in Python 2. >= 6 (using the
__future__
module and py2to3) as well as (even more limited, in my optinon) Python 3 to Python 2. >= 6 with the py3to2, but for a very large percentage of code -- there simply isn't a way to make it work.In along with the addition of generators (making some function calls from 2.x simply not work in Python 3) many of the major frameworks have not made it to Py3k. Django comes to mind, and, if I'm not mistaken Hg is also in Python 2 still.
You don't specify what operating system you're on. It's been my experience that installing multiple Python versions alongside one another tends to just work. For example on Ubuntu it's simply a matter of installing both the 2.x and 3.x packages (using
sudo apt-get install
or Ubuntu Software Centre):I even have a third version (an EPD build) installed on the same box:
I'm not sure I understand your question, but I'll take a shot. I'm also assuming you're on Windows.
It's simple -- just install both. They will install to different directories, create different start menu folders, etc. I'd also reccomend PyWin32 for the PythonWin editor installed in both 2.7 and 3.2,
If you mean how do you write one script that works with either Python 2 or Python 3, look at http://docs.python.org/library/2to3.html