Multiple inheritance, super() and changing signature
ian.g.kelly at gmail.com
Fri Jun 3 10:39:00 EDT 2016
On Fri, Jun 3, 2016 at 8:06 AM, Nagy László Zsolt <gandalf at shopzeus.com> wrote:
>>> That's overly strict. As Raymond shows, it is easy to deal with
>>> changing method signatures in *cooperative* classes.
>> I must watch that for sure.
> All right, I have read this:
> There is still something I don't get: how to create cooperative classes
> when some base classes share some of the parameters?
Why do they need to share the same parameter? Part of cooperative
design is that you can't really design each class in a vacuum; you
need to take the other classes they might get combined with into
account. Perhaps you can extract that parameter into another base
class that is shared by both:
def __init__(self, *, param1, **kwds):
self.param1 = param1
def __init__(self, *, param2, **kwds):
self.param2 = param2
def __init__(self, *, param3, **kwds):
self.param3 = param3
class X(A, B):
A and B can both depend on having param1 without stomping on each
other because they both inherit Root which requires it.
More information about the Python-list