[Zope-dev] Extension class and __init__

Chris Withers chrisw@nipltd.com
Sat, 27 Jul 2002 10:30:11 +0100


Ross Boylan wrote:


> class ECSpam(Base, Spam):  #Base is an ExtensionClass
>   def __init__(self):
>     ECSpam.inheritedAttribute('__init__')(self)
> 
> 
> What if you have more than one base class with the method defined?

The normal Python inheritted attribute lookup rules: depth first, left to right 
through the list of base classes.

> The implication of th example is that the non-extension class base
> class is used 

If Spam defines __init__ and Base doesn't, that would be the case...

> (though even that is not clear; would this work if Base
> had __init__?),

No, in that case Base's __init__ would be used, see python inheritence rules.

> but what if there are several non-extension base
> classes?

See python inheritence rules...

> The syntax doesn't provide a way of indicating which class you want
> the method from, and so it seems incomplete.

Well, if you wanted it to come from Base specifically, you could do:

Base.inheritedAttribute('__init__')(self)

not sure about the non-EC bases, perhaps Jim could clarify this?

cheers,

Chris

> 
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )
> 
>