Ron Adam wrote:

> I presume you meant:
> 
>     def f():
>       x = 42
>       def g():
>         def h():
>           parent x
>           x = 88
> 
> 
> The x would be a new local x in function g and have no effect on the x in 
> function f.  Parent would do exactly what it means in this case, its a 
> reference 
> to a name in only the parent scope.

This *is* confusing, even if the word "parent" is a slight hint on what's
really going on.

> Unless you were to do:
> 
>     def f():
>       x = 42
>       def g():
>         parent x
>         def h():
>           parent x
>           x = 88
> 
> Then all references to x would be the local x in function f.

"So why do I have to declare x in g, if I don't use it there?" This is really
ugly.

Georg

_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to