How to subclass a family
Antoon Pardon
antoon.pardon at rece.vub.ac.be
Mon Apr 8 05:44:51 EDT 2013
Here is the idea. I have a number of classes with the same interface.
Something like the following:
class Foo1:
def bar(self, ...):
work
def boo(self, ...):
do something
self.bar(...)
What I want is the equivallent of:
class Far1(Foo1):
def boo(self, ...)
do something different
if whatever:
self.bar(...)
else:
Foo1.boo(self, ...)
Now of course I could subclass every class from the original family
from Foo1 to Foon but that would mean a lot of duplicated code. Is
there a way to reduce the use of duplicated code in such circumstances?
--
Antoon Pardon
More information about the Python-list
mailing list