I'm migrating a legacy codebase at work from python 2.4 to python 2.6. This is being done as part of a push to remove the 'legacy' tag and make a maintainable, extensible foundation for active development, so I'm getting a chance to "do things right", including refactoring to use new 2.6 features if that leads to cleaner, more robust code. (I'm already in raptures over the 'with' statement :)). Any good tips for the migration? Best practices, design patterns, etc? I'm mostly a ruby programmer; I've learnt some python 2.4 while working with this code but know nothing about modern python design principles, so feel free to suggest things that you might think are obvious.
I guess you have already found them, but reference and for others, here are the lists of new features in those two versions:
Apart from picking features from those documents, I suggest using the opportunity (if needed) to make the code conform to the standard Python code style in PEP 8.
There are some automated tools that can help you getting the Python style right: pep8.py implements the PEP 8 checks and pylint gives a larger report that also includes things like undefined variables, unused imports, etc. pyflakes is a smaller and faster pylint.
Read the Python 3.0 changes. The point of 2.6 is to aim for 3.0.
From 2.4 to 2.6 you gained a lot of things. These are the the most important. I'm making this answer community wiki so other folks can edit it.
Generator functions and the yield statement.
More consistent use of various types like
list
anddict
-- they can be extended directly.from __future__ import with_statement
from __future__ import print_function
Exceptions are new style classes, and there's more consistent exception handling.