Re: raising an exception when multiple inheritance involves samebaseThank

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Hines

    Re: raising an exception when multiple inheritance involves samebaseThank

    Thanks very much, Arnaud. That is exactly the hint I needed. Since it is
    not multiple inheritance per se I prohibit but only multiple inheritance
    involving more than one HocObject class, I replaced your len(bases) 1
    test with
    <code>
    m = False
    for b in bases :
    if hasattr(b, '__mro__'):
    for bb in b.__mro__ :
    if bb == MetaHocObject.h o :
    if m == True:
    raise Exception("Inhe ritance of multiple HocObject not
    allowed")
    m = True

    </code>
    to get

    class A(HocObject): pass

    class B(object): pass

    class C(): pass

    class D(C, B, HocObject): pass # ok

    class D(C, A, HocObject): pass # fail

    When I fold this idea into my code I may even try to eliminate the class
    factory aspect of
    class Foo(hclass(h.Ve ctor))
    in favor of
    class Foo(h.Vector)

    Thanks again,
    Michael


Working...