I am pretty much brand new to Python. I'm cramming this week trying to learn it and I've been handed some code samples to try them out and familiarize myself with them. Problem is that they were written years ago in Python 2. It's my own C++ code that I gave a guy years ago who converted them to Python 2 when he was learning both languages. Now I'M learning Python. I've only used Python 3 and like I said, I'm at the Newbie end of the learning curve. My question is rather generic. One, is there a way to run Python 2 code on my Python 3 installation without porting it line by line (i.e. can I simply put some line at the top of this old code and tell Python to interpret it using Python 2 rather than Python 3)? I assume that porting it from Python 2 to Python 3 will be quite difficult for me to do since, as mentioned, I'm a Python noob. Two, is Python 2 worth bothering to learn or is it obsolete? If not obsolete, should I learn Python 3 first, then Python 2, or vice versa, or learn them concurrently? And is Python 3 like C++11 (i.e. just adding on options that you can use, but all the old code should work when using the new C++11 compiler option. That one I already know the answer to. No. For example,
print "Hello World" does not work in Python 3 (need parentheses in Python 3), but I don't know why (again, noob).
Again, just looking for general advice here. I have a week to learn Python and take a test for a job, so I don't have a whole lot of time to waste and want an efficient learning curve. There are lots of code samples out there. I just wanted to try this particular code out since I was the original author of it in C++ and my friend ported it to Python 2, so it would be interesting to compare/contrast, but not critical and probably not worth it if it's too labor-intensive. Thanks.