A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2004-April/044613.html below:

[Python-Dev] PEP 289 - Generator Expressions

[Python-Dev] PEP 289 - Generator Expressions - Let's Move ForwardEdward Loper edloper at gradient.cis.upenn.edu
Fri Apr 30 12:29:04 EDT 2004
> Hello Guido,
> 
> I did a quick review of the stdlib, including the tests, to see which list
> comprehensions could be replaced with generator expressions.  Thought I admit
> I am biased towards early binding, I ended up looking for cases with the
> following properties:  [...]

Even if we switched to early binding, won't these issues still bite you 
with mutable values?  E.g.:

     some_dict = {'x': 1, 'y': 2}
     iter1 = (some_dict.get(v, 3) for v in input1)
     some_dict['z'] = 5
     iter2 = (some_dict.get(v, 7) for v in input2)

It seems like it would be surprising (to me, anyway) if this gave a 
different result than:

     some_dict = {'x': 1, 'y': 2}
     iter1 = (some_dict.get(v, 3) for v in input1)
     some_dict = {'x': 1, 'y': 2, 'z': 5}
     iter2 = (some_dict.get(v, 7) for v in input2)

-Edward


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4