Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I visited Slashdot this morning to find out that Python 3.0 has been released. I know C# and Perl, but have wanted to learn Python for some time, especially after I saw its ease of use to create useful tools, not to mention its use in game scripting.

My question is, how does the intentionally backwards-incompatible release of Python 3.0 affect adoption, and should I learn Python 2? Or should I take the dive and learn Python 3.0 first, and wait for the libraries to be ported?

share|improve this question

migrated from stackoverflow.com Jan 30 '11 at 20:09

This question came from our site for professional and enthusiast programmers.

1  
After 2 years of hindsight, I'm going to guess "Yes." ;) –  Bill the Lizard Jan 30 '11 at 20:09
    
With 5 years of hindsight, I'm still going to guess the answer is "Yes" ;) –  jozefg Dec 17 '13 at 2:56

5 Answers 5

I think it will hurt for a time, but not as bad ad PHP4 to PHP5 is. As is mentioned by someone else, the biggest issue is "Are the libraries I use ported?" There will continue to be dual releases of Python 2.X and 3.X for a time for the purpose of slowly transitioning people. is it worth it for a large system that is in maintenance mode? Probably not (until something bad happens).

There is a great porting guide though and they have tried to make the transition as easy as possible. The one note I would add to it is "Make sure you are importing all the __ future__ statements possible (like print as a function). I don't know how the 2to3 script handles it but that at least gets you some of the code changed and tested.

portingGuide = """ For porting existing Python 2.5 or 2.6 source code to Python 3.0, the best strategy is the following:

  1. (Prerequisite:) Start with excellent test coverage.
  2. Port to Python 2.6. This should be no more work than the average port from Python 2.x to Python 2.(x+1). Make sure all your tests pass.
  3. (Still using 2.6:) Turn on the -3 command line switch. This enables warnings about features that will be removed (or change) in 3.0. Run your test suite again, and fix code that you get warnings about until there are no warnings left, and all your tests still pass.
  4. Run the 2to3 source-to-source translator over your source code tree. (See 2to3 - Automated Python 2 to 3 code translation for more on this tool.) Run the result of the translation under Python 3.0. Manually fix up any remaining issues, fixing problems until all tests pass again.

It is not recommended to try to write source code that runs unchanged under both Python 2.6 and 3.0; you’d have to use a very contorted coding style, e.g. avoiding print statements, metaclasses, and much more. If you are maintaining a library that needs to support both Python 2.6 and Python 3.0, the best approach is to modify step 3 above by editing the 2.6 version of the source code and running the 2to3 translator again, rather than editing the 3.0 version of the source code.

For porting C extensions to Python 3.0, please see Porting Extension Modules to 3.0. """

share|improve this answer
    
Your porting link is broken. I think you want: docs.python.org/3/howto/pyporting.html –  Jace Browning Jul 16 at 17:19

I don't think it will affect adoption in the long run, but it certainly won't be painless. Python's motto and strategic advantage has always been "Batteries Included". This was not only due to the Standard Library, but also due to the many external libraries. Will libraries like NumPy, SciPy, WxPython, PyGame (just to name a few) work from day one? It will take some time foreverything to consolidate. Also, what about older systems that have an old 2.x version of Python. In few years from now I may found out that I need to update a library. Will the library author continue to support the 2.6 version so that I have a choice? For how long will 2.6 distributions be available for legacy systems? A change of this size is never easy.

For someone starting to use Python now, I suggest to go with Python 2.6, which is actually a bridge between the two worlds.

share|improve this answer
    
We have just a few Python scripts at work and the new way to use the print functionality means that we have to plan a transition where everyone upgrades to Python 3 at the same time, or the script won't run on all machines (depending on wether we change it or not), so I think it is a real issue. –  Lasse V. Karlsen Dec 5 '08 at 23:55
1  
@lassevk, Python 2.6 sounds like what would work best for migrating in your case. You can use the print statement like old versions, and also use the new function by using 'from future import print_function', so that you can migrate incrementally. The same applies to unicode_literals. –  Adam K. Johnson Dec 6 '08 at 5:39

Python 2.6 is the bridge to 3.0.

Backward compatibility is a complete non-issue. It's minor, isolated and specialized. There are only a few things that most people will notice are incompatible, primarily the loss of the print statement.

There's a specific conversion strategy and tools for checking your code for compatibility and making the necessary changes.

It will be painless. Learn with 2.6, using the 3.0 features. It'll all be good.

share|improve this answer

I don't think anyone expects Python 3 to be instantly adopted. As far as I know, GvR is still planning on supporting the 2.x line for several more years while Python 3 gathers momentum.

I think the signal that the transfer is complete will be when the O'Reilly books update to 3.x. Until then, it's transitional. :)

share|improve this answer

For me, personally, the moment I start using it for real work (over 2.5) will be when it becomes ubiquitous among linux distributions (particularly debian/ubuntu). At the very least, it needs to be in an apt repo somewhere.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.