Class attribute or instance attribute?
aahz at pythoncraft.com
Mon Apr 28 22:39:00 CEST 2003
In article <vaqtlsqbi52j93 at corp.supernews.com>,
Paul Watson <pwatson at redlinec.com> wrote:
>My biggest question is why self.v has a value of "Consequences" in the
>_init__() of f2? Is self.v not an instance variable?
When an attribute lookup fails in an instance, Python searches the
namespace of the parent class and all of the parent's base classes (but
*not* the namespaces of the metaclasses).
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"In many ways, it's a dull language, borrowing solid old concepts from
many other languages & styles: boring syntax, unsurprising semantics,
few automatic coercions, etc etc. But that's one of the things I like
about it." --Tim Peters on Python, 16 Sep 93
More information about the Python-list