I want to learn Python. I have a course to do in Python 3. However, I will need to use mainly the matplotlib and Numpy, and these libraries are not yet compatible with Python 3. Is it worth doing the course in Python 3 or will be a waste of time to learn Python 3 and then ca开发者_开发百科me back to Python 2.x?
What would you do?
FYI, Matplotlib is now ported to Python 3.
You won't have a problem going back to Python 2.x after learning Python 3, or vice versa. There aren't too many differences. (Some standard library changes, print is a function, all strings are unicode -- you'll never notice most of them).
Realistically, if you learn Python 3 now, and get a job working with Python, you will almost definitely be working with Python 2.x for right now. Python 3 hasn't gained wide adoption yet. However, Python 3 will be more adopted in the near future, as a number of libraries are being ported to Python 3.
If you need to use Matplotlib specifically, then you should use Python 2.7 (no sense in using Python 3 right now if the library you need doesn't work for it). But learning Python 3 first will by no means put you at any disadvantage and may put you ahead of the curve when most people finally make the switch.
There's also nothing stopping you from using both (Python 3 for learning/experimenting, Python 2.7 for work).
"What would you do?"
I would port matplotlib to Python 3. :-)
But no, a course in Python 3 is not wasted. The differences are mainly in the standard library, and in subtle internal differences.
The major differences in the language itself is that the unicode type is called str in Python 3, and that print
is a function. The differences are not so big that a course is wasted.
Another way to go is using something like cython which allows you to generate native python libraries that are compatible (without using 2to3 or 3to2) with both 2.x and 3.x. However, it is a bit of work. You do get to use set and dict comprehensions with versions of python that don't support those features though.
精彩评论