Closed davidfstr closed 5 years ago
Hi David. This is due to the fact that I was not sure if the people who are going through these exercises would have Python 3 installed. Python 3 has some very nice things! It's a bummer that they made some functions incompatible. Maybe I'll change the examples to Python 3 in the summer.
There will probably have to be a section at the start of the book around installing Python in any case since you can't guarantee whether any version of Python is installed at all, or if it is installed what version it is at. Therefore you likely have the freedom to select any version of Python you want.
Supporting Python 3 in new teaching materials is the best choice for the Python community so that more developers migrate to the current version.
In case you're wondering, here are the versions of Python that ship with some common operating systems:
Regarding converting Python 2 code to Python 3, you may want to take a look at the 2to3 tool.
Many students still do their homework on University labs. I just checked here at UC Irvine, and the machines are still on Python 2.6.6 :-/ I can ask the support people to upgrade, and they'll probably tell me it won't happen until N months from now or worse. In either case, this is just 1 university. Because of these operational issues, it is unfortunate that backwards compatibility has been broken. It's going to take a while until everyone moves over to 3.
How about creating a new branch containing the 2to3 conversion? People using python 3 can checkout this branch.
2to3 is really not advised. It often breaks Python 2 compatibility to achieve Python 3 compatibility. Consider futurize or modernize instead.
It would be helpful to indicate which version(s) python your code has been tested on. This is my first time visiting, and I had to search for clues about python versions (i.e. looking for "print") before winding up here. Even given that your python is written for 2.*, there are differences between the versions.
@jimmahoney look at #37 for Python 3 related modifications
Good news! I'm finally porting the code to Python 3! It will happen over the next couple of weeks.
Glad to hear the examples are coming to Python 3!
For most code there shouldn't be much difference between Python 2 and 3. I'm guessing you'll just need to add ()s after your prints. And maybe open files slightly differently. But that's probably it. If you do it carefully, the code will work on both Python 2 and 3 without modification.
Check out the latest commit -- EPC for Python 3 is here!
All of the Python examples are written in Python 2 instead of Python 3. I think it would be a good idea to encourage the use of Python 3 in newly written materials given that Python 2 has been feature-frozen since July 2010. Python 3 is the future.
Did you have a specific reason around using Python 2?