variable declaration

Fredrik Lundh fredrik at pythonware.com
Tue Feb 1 01:58:21 EST 2005


Michael Tobis wrote:

> This is definitely a wart:
>
> ... z = 42.3
> ...
> ... def f():
> ...    if False:
> ...       global z
> ...    z = -666
> ...
> ... f()
> ... print z

no, it's a declaration.  from the documentation:

    http://docs.python.org/ref/global.html

    "The global statement is a declaration which holds for the entire
    current code block."

    "the global is a directive to the parser. It applies only to code
    parsed at the same time as the global statement"

</F> 






More information about the Python-list mailing list