Consider the following example:
import types
methods = ['foo', 'bar']
def metaMethod(self):
print "method", "<name>"
class Egg:
def __init__(self):
for m in methods:
self.__dict__[m] = types.MethodType(metaMethod, self)
e = Egg()
e.foo()
e.bar()
What should I write instead of "<name>"
, so output be
method foo
method bar