def methodA(cl):
    with cl.gettrans():
        print('A')


class Child(Parent):
    pass

@staticmethod
def gettrans():
    return transact2()
p = Parent()
p.methodA()
c = Child()
c.methodA()
python: cleanest way to wrap each method in parent class in a "with"