I need to pass an instance method as an argument to a function:
class C(object):
def m(self):
print("m",self)
def f(l,b):
for z in l:
b(z)
x = C()
f([x], lambda c: c.m())
is there a better way than the lambda?
It appears that f([x], C.m) works too, but is this an accident or an official feature?
C.mwill be a reference to an unbound method (as in no associatedselfinstance). Passing<instance>.mwould work though.