PEP 289: Generator Expressions (please comment)

Skip Montanaro skip at pobox.com
Mon Oct 27 12:22:49 EST 2003


    Alex> Let's see: today, I could code: sum([x*x for x in roots]) In 2.4,
    Alex> I will be able to code instead: sum(x*x for x in roots) with some
    Alex> performance benefits.  Could you please explain how using the
    Alex> lighter-weight simple parentheses rather than today's somewhat
    Alex> goofy ([ ... ]) bracketing "generally decreases readability"...?

How is using [...] to construct a list "somewhat goofy"?  For list
comprehensions using square brackets to surround the expression make sense
to me.  If they hadn't been done that way, you might be looking at using
them to distinguish generator expressions from bracket-less list
comprehensions. ;-)

Skip





More information about the Python-list mailing list