Roy Smith <[email protected]>:
> There're certainly not mutually exclusive. Mutually exclusive means if
> you have one, you can't have the other.
Correct.
The classic inheritance diamond:
class A(B, C):
def add_bean(self):
??? # how to implement
class B(D): pass
class C(D): pass
class D:
def __init__(self):
self.beans = 0
def add_bean(self):
self.beans += 1
def bean_count(self):
return self.beans
cannot be dealt with without A addressing the common base class D. And
once it deals with it, A can be broken by reimplementing C without
inheriting it from D:
class C:
def __init__(self):
self.beans = ""
def add_bean(self):
self.beans += "o"
def bean_count(self):
return len(self.beans)
thus violating encapsulation.
Marko
--
https://mail.python.org/mailman/listinfo/python-list