Python DevCenter
oreilly.comSafari Books Online.Conferences.


PyCon 2007 Wrapup

by Jeremy Jones

I recently attended PyCon 2007. It's interesting to look back on the previous year when trying to figure out where to focus my attention in the next year. In organizing my thoughts, I hope to give you some useful information on what's coming.


I also had the pleasure of sitting down with Guido van Rossum, Python's creator and benevolent dictator for life. This is the first time that backward compatibility is an issue, and Guido addresses what you need to do to prepare, discusses the strengths and weaknesses of the new conversion tool, and points out the benefits of several new language features (for example, full support for Unicode strings). He also discusses the controversy and misunderstanding some of these changes have caused in the Python community, and how they're being resolved.

Python Projects to Watch

The world of Python has many different interesting projects. I surveyed several of them and offer this brief overview.


CPython, or just plain Python, is the "official" implementation of the Python languages. It is implemented in C, which is why it is often referred to as CPython. Python 2.5 came out in September 2006. 2.5 was the first major release since 2.4 Final in November 2004. What's New in Python 2.5 by Jeff Cogswell explains some of the new features.


IronPython is an implementation of Python for the .NET framework. Two interesting uses of IronPython are calling .NET classes, and (perhaps less interesting and more work) other .NET languages calling into IronPython code. In September 2006, Microsoft released IronPython 1.0 final.


In February 2007 (I know, this isn't exactly a 2006 story, but it's worth mentioning), the Jython project released version 2.2 beta. Jython is an implementation of the Python language for Java. This February beta release is interesting because the alpha was released in July 2003. Hopefully this new life is an indicator of more good things to come. I think it is a hugely positive thing to have alternate Python implementations, particularly for other widely used languages and frameworks such as .NET and Java. These implementations provide developers for other languages easy access to everything Python offers by way of clean code, straightforward syntax, and its dynamic nature.


Django is one of several "full stack" web frameworks for Python. Django released 0.91 in January 2006 and 0.95 in August 2006. Django attracted attention in August 2006 when several bloggers announced that Guido had declared Django the web framework for Python. 2006 was a significant year for Django because it gained a tremendous amount of momentum, it provided its users with a great tool for rapid web development, and significant production sites built with it (such as Tabblo) began to appear.


TurboGears took the Python web world by storm in 2005 when Kevin Dangoor publicly released it and accompanied that release with a 20-minute wiki video. The video demonstrated how quickly you could get a project started and how easy it was to get it finished. TurboGears was significant in 2006 for much the same reasons as Django. TurboGears has been able to amass and maintain significant momentum, build a developer community, keep releases coming, and contribute to other projects along the way.


SQLAlchemy is an object relational mapper (ORM) that is different from the few for Python I've used. Typically, an ORM class corresponds to exactly one database table. SQLAlchemy provides more flexibility. One ORM class doesn't have to correspond to just one database table. From what I've seen, SQLAlchemy can accommodate as complex of a mapping as you can imagine. SQLAlchemy released 0.1.0 in February 2006 and has been making steady progress ever since.


IPython is an enhanced Python shell. It is amazingly useful as a Python interactive shell replacement, but it can be used for so much more. In December 2006, the IPython team released version 0.7.3 (an explanation of new features can be found here). In short, the IPython team continues to improve on IPython and make it an integral part of Python development.

Python Cheeseshop

The Python Cheeseshop is a central repository for distributing Python projects and packages. The easy_install script from setuptools checks the Cheeseshop for desired packages to install. The combination of a one-line install command, a central repository for packages, and package dependencies has become a huge benefit to Python users. Currently, the Cheeseshop hosts 2,150 projects. While this is far short of CPAN's 11,200+ packages, it is encouraging that so many packages have been posted in such a relatively short period of time.


There are also several useful resources for Python programmers.


ShowMeDo is a website that hosts how-to videos. Several excellent Python videos have appeared there over the course of the year. I expect the number, and the already good quality, will continue to increase.

New Books

Python in a Nutshell (Second Edition) was released in July 2006. The first edition of this nutshell book was an excellent overview of the language, and this second edition brought it up to date with new language features.

Programming Python (Third Edition) is a huge tome filled with all sorts of practical examples of using Python. Again, this third edition updates the book with newer language features.

Top Five Python 3000 Migration Issues

Several changes to Python 3000 will not affect any existing code because they are new features. However, several others will break existing code. Following are five of the biggest changes to Python that will break compatibility with current versions of Python. For each, I offer things to keep in mind as you migrate once Python 3000 arrives. Two suggestions apply for almost all of these five areas: 1) starting with Python 2.6, there will be a command-line option that will show warnings of incompatibility with Python 3000, and 2) the Python dev team is working on a conversion utility to help migrate 2.x code to 3.0 code. I have three more suggestions, which apply to all five areas: 1) unittest, 2) Unittest, 3) UnitTest, 4) UNITTEST, 5) UNITTEST!!! A good test suite will save you from a huge headache when all of these changes come down.

I/O and string Changes

The I/O library is going to become more stackable like Java. While the API should be fairly compatible (you will be able to allocate a simple file object with a call to open()), this is something to watch out for.

The string library is also undergoing a pretty major overhaul. First, all strings will be Unicode. Second, there is a separate bytes type. Again, the API to a string object should remain fairly similar, but the change to Unicode is pretty significant underneath.

For both of these, my only suggestion is to use the 2.6 warning flag and the conversion utility to help spot changes.


The dictionary methods iterkeys(), iteritems(), and itervalues() will be removed in Python 3000. The keys(), items(), and values() methods will return a dictionary view rather than a list. keys() and items() will have set semantics, and values() will support iteration and perhaps not much else. The exact API has not been specified yet, so it is hard to make solid suggestions. However, Guido pointed out an approach to iterating over a sorted dictionary that might ease the migration to Python 3000. A common idiom for iterating over a dictionary is:

d = dict(a=1, b=2, c=3, d=4)
keys = d.keys()
for key in keys:
    print key, d[key]

Guido recommends instead:

d = dict(a=1, b=2, c=3, d=4)
keys = sorted(d.iterkeys())
for key in keys:
    print key, d[key]

Note the use of the sorted() built-in rather than calling sort on the return list. I'm not sure why he recommended using iterkeys() rather than keys(), other than maybe it is easier for the conversion tool to know that iterkeys() is likely a dictionary method and allows it to convert to keys().

The recommendation, then, is to keep in mind how dictionaries are going to behave and which methods are going to become unavailable. Use the conversion utility and see what it does to your code.


In Python 3000, print is no longer a statement, but a function. So:

print "this is a test"


print("this is a test")

The conversion utility should be able to convert print statements to print() functions, so this is a pretty safe change.


Currently, division of two integers returns an integer. In some cases, (such as 1/2), this is a truncating operation. (1/2 returns 0.) In Python 3000, dividing an integer by another integer will return a float, but using // will return an int. The migration suggestion is:

  • Start using from __future__ import division. This will emulate the behavior that will be available in Python 3000.
  • Use // for situations where you know you need truncating integer division.
  • Use / everywhere else.
  • Don't expect much help from the conversion utility on this one.


The exception syntax raise SomeException, argument will not work in Python 3000. Instead, use raise SomeException(argument). Also, except SomeException, v: will not work because v will be deleted at the end of the except block. except SomeException as v: is the proper phrasing in Python 3000. The conversion utility should catch the new except syntax, but I'm not certain about the raise syntax. My suggestion is to use the conversion utility and Python 2.6 flag for except syntax, and test both of those utilities with the raise syntax when they become available.

Python 3000 New Features

In addition to syntax changes, Python 3000 has plenty of new features. For the sake of space, I will only go over a few of them. First, there will be signature annotations. This is simply a way to specify the types of arguments in methods and what type of value a method returns. There will be no built-in enforcement of the annotations, however; this is for documentation and to allow third parties to write, say, decorators to provide enforcement.

Next, keyword-only parameters will be new in Python 3000. This provides syntax to specify that certain arguments are allowable as keyword arguments.

Also, set literals will be included in Python 3000. Instead of set([1, 2, 3]), you will be able to use {1, 2, 3}.

The last new feature I will mention is string formatting. The syntax reminds me of C# string formatting. For example, "{0} => {1}".format("A", "B") will return "A => B".

Python Year (and a Half) in Preview

Python 3.0a1 is scheduled to be released in June 2007. 2.6a1 is scheduled for December 2007 with 2.6 final coming April 2008. 3.0 final should arrive June 2008. I thought it was interesting that 3.0 alpha will be available prior to 2.6 alpha. It is probably helpful to have a working implementation of 3.0 before 2.6 so they can put in better warnings about things that are potentially broken for a user. It looks like "real soon now" is actually going to happen real soon now.

Jeremy Jones is a software engineer who works for Predictix. His weapon of choice is Python.

Return to the Python DevCenter.

Sponsored by: