[Python-3000] Sky pie: a "var" keyword

Ka-Ping Yee python at zesty.ca
Tue Oct 10 15:34:49 CEST 2006


On Tue, 10 Oct 2006, Fredrik Lundh wrote:
> Nick Coghlan wrote:
> > Any proposal such as this also needs to addresses all of the *other* name
> > binding statements in Python:
> >
> >    try/except
> >    for loop
> >    with statement
> >    def statement
> >    class statement
> +    import statement
> +    list comprehension (in 2.X)

The only sane proposal i've seen that consistently addresses all
these cases, doesn't create new ambiguous situations, and doesn't
break most existing Python code is the "nonlocal" declaration.

    nonlocal x

means

    "Don't make a new binding for x in the local scope."

With this declaration, any binding statements modify the x that
is visible from an outer scope instead of creating a local x.


-- ?!ng


More information about the Python-3000 mailing list