How to I make sure functions in the superclass show up in the subclass
without being defined there?
I have a subclass that adds graphics capabilities to a superclass that
implements the algorithms. So, in addition to a few extra initialization
functions, this subclass will only need to refresh the graphics after the
execution of each algorithm-computing function in the superclass.
Classes:
class graph(algorithms):
... #initialization and refresh functions
def algorithm1(self, *args, **kwargs):
algorithms.algorithm1(self, *args, **kwargs)
self.refresh()
def algorithm2(self, *args, **kwargs):
algorithms.algorithm2(self, *args, **kwargs)
self.refresh()
... #and so on
Is there an pythonic way to automatically decorate all the non-private
methods defined in the superclass, such that if I add a new algorithm
there I don't need to explicitly mention it in my subclass? I would also
like to be able to explicitly exclude some of the superclass' methods.
No comments:
Post a Comment