> >[name withheld] > > > The implementation could synthesize a generator function abusing default > > > arguments to give the generator's frame locals with the same names. [Guido] > >Yes, I think that could work -- I see no way that something invoked by > >the generator expression could possibly modify a variable binding in > >the surrounding scope. [Samuele] > so this, if I understand: > > def h(): > y = 0 > l = [1,2] > it = (x+y for x in l) > y = 1 > for v in it: > print v > > will print 1,2 and not 2,3 > > unlike: > > def h(): > y = 0 > l = [1,2] > def gen(S): > for x in S: > yield x+y > it = gen(l) > y = 1 > for v in it: > print v Argh. Of course. No, I think it should use the actual value of y, just like a nested function. Never mind that idea then. --Guido van Rossum (home page: http://www.python.org/~guido/)
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