Generator expressions v/s list comprehensions

Paul Rubin http
Mon Aug 30 04:23:16 EDT 2004


aleaxit at yahoo.com (Alex Martelli) writes:
> It would sure be nice if Python had been born back from day one with all
> the neat features it has taken years to develop -- that way we wouldn't
> have any issues that are there just because of backwards compatibility.
> 
> Unfortunately, this wish is totally unrealistic -- obviously people do
> come up with cool ideas such as the iterator protocol, and generators,
> after the language has been around for a while. 

And yet a lot of the unrealisticness comes directly from the Python
culture.  Maybe it took a while to think up the iterator protocol, but
what about nested scopes?  What about the += operator?  How about the
sorted() method on lists?  One could go on and on with more examples
like that.  These things exist in other languages and had been
requested in Python for years before they got accepted.  And every
time some little thing gets added changing the language, that creates
a new mini-dialect that users have to remember for a while and then
forget.  The result is "version fatigue"; one gets bleary trying to
remember what's in the language this week.  Those features are in
other languages for a reason, and there's been enough experience using
them (in those languages) that their desirability for Python should
never have seriously been in question.  So it would have been better
to include them from the beginning, instead of through separate
episodes of prolonged agony for each one.



More information about the Python-list mailing list