[Python-Dev] scoping and list comprehensions

Greg Ewing greg@cosc.canterbury.ac.nz
Thu, 31 May 2001 17:15:24 +1200 (NZST)


Skip:

>    scope:
>        l = [i**2 for i in range(10)]

By analogy with C, the introducer of a new scope should
simply be an unadorned colon:

  :
    l = [i**2 for i in range(10)]

:-)

While this might be useful, it doesn't really address the issue
raised, because we really need a new scope per listcomp (or
maybe even each 'for' in the listcomp).

> There's also the problem of how to export results from the scope, though
> perhaps the new nested scope stuff provides a solution to that.

Nope -- there's still no way to assign to any name in
an intermediate scope. Something heretical, such as
declarations, would be needed.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg@cosc.canterbury.ac.nz	   +--------------------------------------+