|
|
| | Ask HN: start with python 2.6 or 3? | |
31 points by jgamman on July 4, 2009 | hide | past | favorite | 17 comments
|
| | if you were learning python right now as your first language and you wanted it to play well with others (django, scipy, matplotlib, GAE etc) - do you start with something stable with loads of documentation and then migrate to python 3 (heck it's 3.1 already) or do you skip the mental overhead of unlearning some things that'll get baked in by using 2.6? |
|
Consider applying for YC's first-ever Fall batch! Applications are open till Aug 27.
Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact
|
Note that both Python 2.6 and 3.1 are considered stable production releases, but if you don't know which version to use, start with Python 2.6 since more existing third party software is compatible with Python 2 than Python 3 right now.
If you're just learning to program now, you'll have an easier time if you stick to the officially sanctioned features of Python, rather picking up bad habits from deprecated back roads. There aren't many of them in Python 2 compared to some other languages, but if you want to be safe, Python 3 was meant to eliminate as many of those as possible. You'll get a similar benefit if you follow the official Python 2.6 tutorial first, before reading introductory Python books that were written before Python 2.6 was released.
To be super specific, these are the things that you should try to stay up to date on:
1. Unicode support in strings
2. "New-style" versus "old-style" classes
3. The "with" statement, and context managers
4. Generator functions and expressions, versus list comprehensions and plain ol' for loops
If you watch out for these, and read the "What's New in Python X.Y" documents for each version between the one you started on and the newest release, the transition shouldn't be too hard.
The projects you're depending on may also offer some hints about when they'll do the 3.X transition. SciPy depends on Numpy, which depends heavily on the Python 2.X C extension API and will take a long time to convert. Django is basically pure Python and can probably convert sooner. GAE is Google's infrastructure and will probably be 2.X for years.