Writing backwards compatible code

Felipe Almeida Lessa felipe.lessa at gmail.com
Fri Apr 14 14:42:39 EDT 2006


Em Sex, 2006-04-14 às 13:37 -0500, Robert Kern escreveu:
> Felipe Almeida Lessa wrote:
> > Em Sex, 2006-04-14 às 13:28 -0500, Robert Kern escreveu:
> > 
> >>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?
> > 
> > Right. You can always use classes.
> 
> Well, I guess you could, but using actual generators would be much cleaner.

That's the whole point around syntactic sugar: being cleaner, more
concise, (sometimes) less error-prone and (less times) faster.

-- 
Felipe.




More information about the Python-list mailing list