PEP 289: Generator Expressions (please comment)

Christoph Becker-Freyseng webmaster at beyond-thoughts.com
Thu Oct 23 20:58:03 EDT 2003


Raymond Hettinger wrote:
> creating fast, memory efficient generator expressions on the fly:
> 
>     sum(x*x for x in roots)


+3.1415

Especially I like the boost of use of many python-standard-functions -- 
like min, max, ... :-)
Furthermore the syntax is quite clear and readable.
However I'm a bit worried if some could get into trouble because of the 
difference between using Generator Expressions in function-call with one 
  argument and a call with more than one arguments.


Christoph Becker-Freyseng


BTW: Python is getting more and more stuff. So I fear that some code 
might get harder to read for newbies (not knowing all the new stuff).

Would it be possible to make an expression-/statement-parser that can 
analyse a code snippet (one line of python-code maybe more) and tell the 
user what syntax-constructs were used.

This might be a big help when reading code and if you don't know some 
special construct.

e.g.:
    newstuff.py:
       ...
       sum(x*x for x in roots)
       ...
    ??? Mmmm What's that
    pyscryer "sum(x*x for x in roots)"
       <Function-Call>(<Generator Expression>)

Then you can search the Internet to close your knowledge gap (you can't 
search for "sum(x*x for x in roots)", but "python Generator Expression" 
might be succesful)







More information about the Python-list mailing list