Let's say I have a class defined like this:
classA():
def do_one():
print("one")
def do_two():
print("two")
def some_other():
print("other")
I want to create a derived class and automatically define every method from the parent class that starts with do
I tried this:
class B(A):
pass
for m in dir(A):
if m[0:3] == "do_":
def dm(self):
print("somebething before")
getattr(super(),m)()
dm.__name__ = m
setattr(B,m,dm)
But i'm getting this error: RuntimeError: super(): __class__ cell not found
Also is there a non-so-hacky/pytonic way of achieving this?