I am currently working on a problem where many classes will be based on a base class. I want these classes to inherit a static function from the base class which in turn calls a static function. This second static function will, however, be defined for each class.
A simple example would be:
class foo():
@staticmethod
def fn1(x):
return x
@staticmethod
def fn2(x, y):
return foo.fn1(x + y)
class bar(foo):
@staticmethod
def fn1(x):
return 2*x
With the above code bar.fn2(1, 2) returns foo.fn1(1 + 2) and I would instead like it to return bar.fn1(1 + 2).
Is this possible to do with static methods in python without defining fn2 for each class?
Grateful for any help!