I would like to modify an initializer of a class at run-time. Are there any potential catches with a code like this? I'm new into decorators so not really sure.
class Object:
def __init__(self):
print "do something"
@classmethod
def modify(cls, f):
__init___old = cls.__init__
def __init__(self):
__init___old(self)
f(self)
cls.__init__ = __init__
return f
@Object.modify
def f(self):
print "do something else"