decorating a method in multiple child classes
1x7y2z9 at gmail.com
1x7y2z9 at gmail.com
Thu Jul 17 15:58:56 EDT 2008
Say, we have a (parent) class P.
It has N child classes C1(P), C2(P) ... CN(P)
Each of the child classes defines (differently) a method func().
I wish to decorate all of the CX.func() in the same way. One way to
do this is to add a decorator to each of the derived classes. But
this is tedious and involves modifying multiple files.
Is there a way to modify the parent class and have the same effect?
Or some other way neater than the above?
Thanks.
visual:
class P(object):
...
class C1(P):
def func(self, ...):
...
class C2(P):
def func(self, ...):
...
More information about the Python-list
mailing list