Nested scopes hitch

Aahz aahz at pythoncraft.com
Mon Apr 8 19:49:53 EDT 2002


In article <mailman.1018261577.4898.python-list at python.org>,
Graham Ashton  <gashton at cmedltd.com> wrote:
>
>I remember being slightly surprised by the fact that self finds class
>variables. Is there any particular reason why, considering that the you
>can reference them as ClassName.var anyway?

It's part of the whole superclass lookup mechanism:

    class A:
        def foo(self):
            print "!"

    class B(A):
        pass

    B().foo()
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"There are times when effort is important and necessary, but this should
not be taken as any kind of moral imperative."  --jdecker



More information about the Python-list mailing list