[Python-Dev] problem with genexp

Neal Norwitz nnorwitz at gmail.com
Tue Oct 11 07:14:44 CEST 2005


On 10/10/05, Brett Cannon <bcannon at gmail.com> wrote:
> On 10/10/05, Neal Norwitz <nnorwitz at gmail.com> wrote:
> > There's a problem with genexp's that I think really needs to get
> > fixed.  See http://python.org/sf/1167751 the details are below.  This
> > code:
> >
> > >>> foo(a = i for i in range(10))
> >
> > generates "NameError: name 'i' is not defined" when run because:
> [SNIP]
> > If you add parens around the code:   foo(a = i for i in range(10))
> > You get something quite different:
>
> Do you mean having ``(foo(a = i for i in range(10))``?  Otherwise I
> see no difference when compared to the first value.

Sorry, I think I put it in the bug report, but forgot to add it here:

>>> foo(a = (i for i in range(10)))

n


More information about the Python-Dev mailing list