A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-October/039207.html below:

[Python-Dev] accumulator display syntax

[Python-Dev] accumulator display syntax [Python-Dev] accumulator display syntaxGuido van Rossum guido at python.org
Tue Oct 21 18:14:19 EDT 2003
> >[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/)

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