I'm starting a new python project at work that is targeted primarily at RHEL5 machines that may be upgraded to RHEL6 in couple years. Given that python 2.4 is standard on RHEL5 and the system admins won't support more than they have to, getting python 2.6 in our local repo will take some convincing. While it seems I could get by just fine with python 2.4, I feel leery about creating a project from the ground up aimed at being 100% compatible with such an old version.
Should I fight for having this project done in 2.6 or aim for the smoothest compliance with RHEL5? What are the pitfalls I should be aware of if I stick with 2.4?
FYI: I'll definitely be using sqlite, and pygtk.
Your best bet is probably to stick with 2.4, and have a time_machine module with all the goodies that later pythons have that you want. For example, when properties first came out you had to do something like:
def _get_prop(self):
return self._prop
def _set_prop(self, value):
self._prop = value
prop = property(_get_prop, _set_prop)
but in 2.6 they enhanced properties to also be decorators themselves, so then you could write:
@property
def prop(self):
return self._prop
@prop.setter
def prop(self, value):
self._prop = value
which means less redundant functions hanging around in your class' namespace.
I happen to like that feature a lot, so my time_machine.py has code similar to:
# 2.6+ property for 2.5-
if sys.version_info[:2] < (2, 6):
# define our own property type
class property():
"2.6 properties for 2.5-"
def __init__(self, fget=None, fset=None, fdel=None, doc=None): ...
def __call__(self, func): ...
def __get__(self, obj, objtype=None): ...
def __set__(self, obj, value): ...
def __delete__(self, obj): ...
def setter(self, func): ...
def deleter(self, func): ...
The really nice part about this is that python equivalents are often used to demonstrate the new functionality, so you don't even have to write the code yourself.