[Python-3000] The meaning of "global variable"

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Fri Nov 3 21:33:18 CET 2006


Ron Adam <rrr at ronadam.com> writes:

> How about limiting nonlocal to just the immediate parent scope and
> using 'parent' as the keyword?

Please don't put unnecessary limits.

There are two ways to refer to a variable: read it or assign it.
Currently reading doesn't create a new variable, while assigning does
(at the beginning of the function which assigns it).

'nonlocal' should mean: refer to the same variable as would be
referred to if the current function did not assign it, only read it.

I don't care much whether 'global' will be retained as is, or whether
'nonlocal' will actually be spelled 'global'. If I had to decide,
I would keep 'global' with its current meaning because of the name:
"global" means here "a single variable which exists during the whole
duration of the program", not "visible from everywhere", which is
appropriate for the current meaning but not for the proposed 'nonlocal'.

-- 
   __("<         Marcin Kowalczyk
   \__/       qrczak at knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/


More information about the Python-3000 mailing list