how do i add code to an existing function, either before or after?
for example, i have a class:
class A(object):
def test(self):
print
There are a lot of really good suggestions above, but one I didn't see was passing in a function with the call. Might look something like this:
class A(object):
def test(self, deep=lambda self: self):
print "here"
deep(self)
def test2(self):
print "and here"
Using this:
>>> a = A()
>>> a.test()
here
>>> a.test(test2)
here
and here