Class variable inheritance

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Wed Sep 9 08:30:51 CEST 2009


On Tue, 08 Sep 2009 13:14:42 -0700, HPJ wrote:

>> 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?


You must be new to the Internet *wink* 

Of course people ask without having made the effort themselves. "Please 
sir, will you do my work for me?" is practically the norm on Internet 
forums. Only without the please.


> 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.

The inheriting class has its base class set, and the MRO (method 
resolution order), and that's pretty much it as far as I can tell.

Seems to me that the documentation is a little incomplete in this regard. 
It looks to me like one of those "language lawyer" details that needs 
fleshing out.

Out of curiosity, are there languages where inheritance means copy?


-- 
Steven



More information about the Python-list mailing list