Class variable inheritance

HPJ henrypijames at gmail.com
Tue Sep 8 16:14:42 EDT 2009


> I could, but I will let you read and find what it says about class
> attributes.

You think I would have asked specifically about the Language Reference
if I hadn't read it and failed to find what I was looking for?

The closest thing I was able to find was section 3.2. "The standard
type hierarchy", subsection "Custom classes", where it says:

"When the attribute name is not found [in its namespace dictionary],
the attribute search continues in the base classes. This search of the
base classes uses the C3 method resolution order [...]"

That tells me how the lookup works, which I already knew. But it
doesn't tell me what happens when a class is inherited.

Now, one could argue if the attributes were copied, there would be no
need for a lookup in the base classes, so derivatively it says that's
not the case. To this I would say yes, there still would because after
they've been copied through inheritance, attributes can still be
removed via "del". Anyway, this passage, which is the only one I could
find, doesn't provide a direct and conclusive answer to my question.



More information about the Python-list mailing list