6 ms·
Ask HN: Why are there 2 Pythons? (2.7 & 3.1.2)
Looks to me like both are stable? Which one should you use for new projects?
- makecheck 16y agoIf you're doing something completely new that will never interact with older code bases, Python 3 seems like the best choice. This is where the language is ultimately going. However, if you have to integrate with almost anything in 2.x land, such as 3rd party libraries, you may have no choice but to keep using 2.x for awhile. As usual, even from this older version, there are ways to voluntarily import future capabilities so that your code is as 3.x-like as possible.
- galois 16y ago2.5.4
- adestefan 16y agoPython 3 is not backwards compatible with Python 2. The developers have always stated that Python 3 will be a 5 year project until the entire standard library is ported.
- j_baker 16y agoI think you mean to say "until third party libraries get migrated". The standard library is already migrated.
- devinj 16y agohttp://wiki.python.org/moin/Python2orPython3 http://wiki.python.org/moin/Python2orPython3 was created recently to answer just such a question, quite recently in fact (some people were asking similar questions and the issue of the quality of the stock answers was raised in comp.lang.python).
- sidmitra 16y agohttp://docs.python.org/release/3.0.1/whatsnew/3.0.html http://docs.python.org/release/3.0.1/whatsnew/3.0.html this is down. It was linked in the above article. Google cache: http://webcache.googleusercontent.com/search?q=cache:dqDQ-qwXBRQJ:docs.python.org/dev/3.0/whatsnew/3.0.html+python+3+whats+new&cd=1&hl=en&ct=clnk http://webcache.googleusercontent.com/search?q=cache:dqDQ-qw...
- mkramlich 16y agowhy can't you look in the obvious places to answer such a question without asking that on HN? (hint: Python.org and Google) (no ill will, but an honest counter-question)
- allend 16y agokarma?
- pgbovine 16y agoless cynically ... perhaps the poster wanted the personal opinions of HN hackers, many of whom probably have first-hand experience with Python and might be able to give more personalized answers than what's on FAQ pages
- mkramlich 16y agoahhh, k. so if that's the case, here's what I should do. i'll begin preparing a series of questions to post to HN in the coming weeks, to keep in the same spirit. Rough list to start with: 1. where do babies come from? 2. what is PageRank? 3. what sorts of languages can you write iPhone apps in such that they are allowed in the Apple store? 4. why might I want to write an app in C versus in BASIC? i'll add more as the whim comes to me. ;)
- code_duck 16y agoActually, if you went one step beyond and asked for opinions or non-obvious answers to any of those, I'd consider that perfectly suitable for the site. For example 2. is there an open source implementation of PageRank? 3. any tips on how to fake handwritten Objective C so Apple will accept my app? 4. I wrote my app in BASIC instead of Objective C and Steve Jobs said it was okay
- mkramlich 16y agohere are some more common patterns that HN seems to find acceptable: 1. <something-something-something> Google? 2. <something> Facebook <something> Apple? 3. when will <Apple|Google|Facebook|Amazon> do <my personal whim here>? :P
- awolf 16y agoMy rule of thumb as to when to use Python 3: once django is ported.
- tel 16y agos/django/scipy/ or I suppose re.sub('django', 'scipy', the_above)
- BerislavLopac 16y agoGreat rule of thumb, but this also goes for a whole bunch of auxiliary Django applications and libraries like Piston, Evolution, South etc.
- steamboiler 16y agoI think that once the Django team announces their intention to port most of the auxiliary applications will take notice and follow suit. I base this on how the (better) auxiliaries have been pretty good at keeping in sync with Django's releases.
- PostOnce 16y agoGoogle App Engine SDK uses Python 2.5, I had 2.6 installed and had to revert. 3 drops some features, adds some others. You can import 3.x features in 2.x from __future__, see: http://docs.python.org/library/__future__.html http://docs.python.org/library/__future__.html One of the less useful features dropped is 'somestring'.encode('rot13') :P
- klodolph 16y agoBoth are stable. Both will continue to be stable for a long time. The main difference lies with third party library support. There are a number of third party libraries that don't work with Python 3 yet. They will get ported eventually. If you want to use a library that doesn't support 3, then the choice is made for you. The second difference lies with Linux distributions. On most distros you can just install the "python3" package and everything works, on a few distros you'll have to install Python 3 yourself or hunt down the right package repository (my info may be a year behind or so, I'm not sure). This also applies to third party libraries -- even if the library supports Python 3, your distro might not have a package for it, even if it has a package for that library for Python 2. It's fairly easy (most of the time) to write code for Python 2.x that converts to Python 3 code with the bundled "2to3" converter. I do this for any script I might ever want to give to someone else or run on a computer that's not mine. Otherwise, I just write straight Python 3 code. Assuming, of course, that I don't need some library.
- TrevorBurnham 16y ago> They will get ported eventually. This is what worries me about Python: Python3 has been stable for a long while now, yet major projects (SciPy, Django) remain on 2.x, with no clear deadline for being ported to Python 3. Contrast this to Ruby, where Rails 3 is 1.8-compatible but recommends 1.9. Ruby 1.9 is being used in production even though it's not completely stable yet. In short, Ruby is clearly evolving, major libraries are constantly being updated for the latest version of the language, and everyone in the Ruby community has a strong sense of "getting better all the time." Python 3 is a better language than Python 2. That it's taken so long to become the canonical version makes me wonder about Python's future.
- klodolph 16y agoI don't think the circumstances compare. Python 3.x is different in a bunch of little ways from 2.x. Just like you say Rails 3 runs on Ruby 1.8 and 1.9, most Python libraries will run on 2.5, 2.6, or 2.7 (often 2.4 as well) without modification. Python 3.x breaks these libraries. Python 2.7 is also several months newer than Python 3.1. It reminds me of the 2.4 -> 2.6 transition for the Linux kernel. People were using 2.4 for a long time. Heck, you can still find Linux 2.4 in the wild.
- japherwocky 16y agoIf you have to ask, I would highly recommend 2.x ! Nobody of note is using 3.x in production. It's nice, but not backwards compatible with the huge pool of existing code / docs; which is one of python's strongest suits, especially if you're coming to the language fresh. The IRC /topic: ;) """ Topic for #python: NO LOL | Don't paste in here: use http://paste.pocoo.org/ http://paste.pocoo.org/ | http://pound-python.org/ http://pound-python.org/ | Include Python version in questions | 2.x or 3.x? http://tinyurl.com/python2or3 http://tinyurl.com/python2or3 | Tutorial: http://docs.python.org/tut/ http://docs.python.org/tut/ | FAQ: http://effbot.org/pyfaq/ http://effbot.org/pyfaq/ | New Programmer? http://tinyurl.com/thinkcspy2e http://tinyurl.com/thinkcspy2e | #python-fr #python.de #python-es #python.tw #python.pl #python-br #python-nl #python-ir """
- njharman 16y agoThere are many more than 2 pythons. Several versions 2.6, 2.4, 2.2 happily in use in the wild. Not to mention jython, Stackless, IronPython and the like. Use the one that fits your new project.
- xenoterracide 16y agoSpeculatively, there are more than 2 Pythons. Python, like perl has become a family of languages. Some time ago Perl Mongers accepted that Perl 6 was not the next version of Perl but a new language in the Perl family. I suspect Python 3 is to Python 2 as Perl 6 is to Perl 5. Google's Go is also a language in the python family I think.
- ggchappell 16y ago> Google's Go is also a language in the python family I think. I can't imagine how that statement could be true. Please explain.
- xenoterracide 16y agoC, C++, Java, Javascript are all members of the C family of languages... even if created by different people for different reasons.
- jcapote 16y agoIt's more like 3, since 2.5 is still pretty popular and doesn't work with 2.7 or 3.1