Multiple Inheritance and super()
INADA Naoki
songofacandy at gmail.com
Mon Nov 9 04:30:20 GMT 2009
>> I'm not 100% sure what is 'correct' here.
>
> Deprecate multiple inheritance? (Only half joking.)
Pure mix-in (doesn't have __init__() and any other overriding methods)
is not dangerous.
Cross class overriding is dangerous. So I think it should be avoided.
In case of __init__(), the class that aimed to mixed-in shouldn't have
__init__()
and alternative init() method. For example:
class Base(object):
def __init__(self, a,b,c):
pass
class Mixed(object):
def init(self, foo, bar, baz):
pass
class Mixing(Base, Mixed):
def __init__(self, a, b, c, foo, bar, baz):
supre(Mixing, self).__init__(a, b, c)
Mixed.init(self, foo, bar, baz)
--
Naoki INADA <songofacandy at gmail.com>
More information about the bazaar
mailing list