[Python-Dev] listcomps vs. for loops

Delaney, Timothy C (Timothy) tdelaney at avaya.com
Tue Oct 21 19:39:03 EDT 2003

> From: Guido van Rossum [mailto:guido at python.org]
> > >     for x in R:
> > >         ...
> > >     print x
> > 
> > For which reason I propose that Python 3.0 have the control name in
> > any for expression be "local" to the expression ;)
> What expression?

Sorry - I meant statement.

> If you're talking about making
>   x = None
>   for x in R: pass
>   print x # last item of R
> illegal, forget it.  That's too darn useful.

Note the winking smiley above :) Although I do find the scope limiting in:

    for (int i=0; i < 10; ++i)

to be a nice feature of C++ (good god - did I just say that?) and hate that the implementation in MSVC is broken and the control variable leaks.

> No, and no; we already went over this (but I don't blame you for not
> reading every msg in this thread :-).  It does mean that we have to
> start issuing proper deprecation warnings, and maybe we won't be able
> to properly fix the LC scope thing before 3.0.

Yeah - I realised later that the discussion was hidden in the accumulator syntax thread.

I definitely wouldn't find it confusing, but I've been a proponent of not leaking the control variable all along :)

Tim Delaney

More information about the Python-Dev mailing list