Writing backwards compatible code

Robert Kern robert.kern at gmail.com
Fri Apr 14 14:28:21 EDT 2006


Steven D'Aprano wrote:
> I came across an interesting (as in the Chinese curse) problem today. I
> had to modify a piece of code using generator expressions written with
> Python 2.4 in mind to run under version 2.3, but I wanted the code to
> continue to use the generator expression if possible.

Why? AFAICT, it really is just syntactic sugar. Very nice syntactic sugar, but
not necessary at all. If you are going to have the ugly, syntactically bitter
version in your code anyways, why clutter up your code even more trying to do both?

> What techniques do others use?

Personally, I write code that only uses the syntactic features of the Python
version that I am targetting.

-- 
Robert Kern
robert.kern at gmail.com

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco




More information about the Python-list mailing list