Need help with Python scoping rules
Diez B. Roggisch
deets at nospam.web.de
Tue Aug 25 12:55:41 EDT 2009
Jean-Michel Pichavant wrote:
> Diez B. Roggisch wrote
>> Classes are not scopes.
>>
>>
> Too bad, could have been handy.
Nope. Because then a lot of people would write something like this:
class Foo(object):
def bar(self):
bar() # note the missing self.
And this would lead to errors because self was missing from the call
to "bar".
And you'd need a disambiguation for methodname/global-name-clashes. The
global-statement would work, but then code could break when all of a
sudden a subclass defines a method that hitherto was only known as global.
So via subclassing, you introduce *arbitray* and hard to debug errors.
No. I'm certain, not a good idea.
Diez
More information about the Python-list
mailing list