Migrating from python 2.4 to python 2.6

I am porting an outdated code base to work with python 2.4 on python 2.6. This is done as part of the push to remove the "legacy" tag and create a supported extensible framework for active development, so I get the opportunity to "do it right", including refactoring to use the new 2.6 functions, if this leads to cleaner, more reliable codes. (I am already delighted with the statement "c" :)). Any good tips for migrating? Best practices, design patterns, etc.? I am basically a ruby โ€‹โ€‹programmer; I learned some python 2.4 while working with this code, but I donโ€™t know anything about modern python design principles, so feel free to suggest things that you think are obvious.

+4
source share
2 answers

Read the Python 3.0 changes. Point 2.6 is for 3.0.

From 2.4 to 2.6 you got a lot of things. It's the most important. I am making this answer to the community wiki so that other people can edit it.

  • Generator functions and yield statement.

  • More consistent use of various types, such as list and dict - they can be extended directly.

  • from __future__ import with_statement

  • from __future__ import print_function

  • Exceptions are new style classes and more consistent exception handling. Line exceptions are excluded. Trying to use them raises a TypeError

+5
source

I think you already found them, but the link is for others, here is a list of new features in these two versions:

In addition to selecting functions from these documents, I suggest using (if necessary) the ability to make the code compatible with the standard Python code style in PEP 8 .

There are several automated tools that can help you set up your Python style correctly: pep8.py implements 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 peeling.

+2
source

All Articles