Python's scope rules
Marcin 'Qrczak' Kowalczyk
qrczak at knm.org.pl
Thu Dec 21 08:14:44 CET 2000
Wed, 20 Dec 2000 12:47:09 -0500, Terry Reedy <tjreedy at udel.edu> pisze:
> The only things I find 'odd' (and definitely confusing at first)
> is the use of 'global' for the module namespace (and I suppose
> there is some history here) and the sometimes claim that there are
> two rather than three possible scopes.
The fact that scopes don't nest is a practical problem. Yesterday I was
doing some customizations to viewcvs and wanted to factor out a common
pattern of code of 5 lines which was repeated 5 times by moving it to
a local function, but it referred to so many free local variables that
I finally did not do it, because I would have to pass them explicitly
and the result would not be much less ugly than the current state.
I don't want dynamic scoping like in old Lisp and probably nobody wants
it. But nested lexical scoping is used in other good languages, it's
so natural and convenient that it's odd that Python does not use it.
IMHO Python would be a better language with true lexical scoping.
__("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
^^ SYGNATURA ZASTĘPCZA
More information about the Python-list