python 3's adoption

Mitchell L Model MLMDev at Comcast.net
Thu Jan 28 11:03:20 EST 2010


I have been working with Python 3 for over a year. I used it in  
writing my book "Bioinformatics Programming Using Python" (http://oreilly.com/catalog/9780596154509 
). I didn't see any point in teaching an incompatible earlier version  
of a language in transition. In preparing the book and its examples I  
explored a large number of Python modules in some depth and  
encountered most of the differences between the language and libraries  
of Python 2 and Python 3. The change was a bit awkward for a while,  
and there were some surprises, but in the end I have found nothing in  
Python 3 for which I would prefer Python 2's version.

Removal of old-style classes is a big win. Having print as a function  
provides a tremendous amount of flexibility. I use the sep and end  
keywords all the time. There is no reason for print to be a statement,  
and it was an awkward inconsistency in a language that leans towards  
functional styles. Likewise the elimination of cmp, while shocking,  
leads to much simpler comparison arguments to sort, since all the  
function does is return a key; then, sort uses __lt__ (I think) so it  
automatically uses each class's definition of that. The weird objects  
returned from things like sorted, dict.keys/values/items, and so on  
are values that in practice are used primarily in iterations; you can  
always turn the result into a list, though I have to admit that while  
developing and debugging I trip trying to pick out a specific element  
from one of these using indexing (typically [0]); I've learned to  
think of them as generators, even though they aren't. The  
rearrangements and name changes in the libraries are quite helpful. I  
could go on, but basically the language and library changes are on the  
whole large improvements with little, if any, downside.

Conversion of old code is greatly facilitied by the 2to3 tool that  
comes with Python 3. The big issue in moving from 2 to 3 is the  
external libraries and development tools you use. Different IDEs have  
released versions that support Python 3 at different times. (I believe  
Wing was the first.) If you use numpy, for example, or one of the many  
libraries that require it, you are stuck. Possibly some important  
facilities will never be ported to Python 3, but probably most active  
projects will eventually produce a Python 3 version -- for example,  
according to its web page, a Python 3 version  of PIL is on the way. I  
was able to cover all the topics in my book using only Python library  
modules, something I felt would be best for readers -- I used  
libraries such as elementree, sqlite3, and tkinter. The only  
disappointment was that I couldn't include a chapter on BioPython,  
since there is no Python 3 version.

By now, many large facilities support both Python 2 and Python 3. I am  
currently building a complex GUI/Visualization application based on  
the Python 3 version of PyQt4 and Wing IDE and am delighted with all  
of it. It may well be that some very important large 



More information about the Python-list mailing list