Is it possible to get the function name from a operator.methodcaller in Python?
import operator as op
mc = op.methodcaller('foo')
print magic(mc) #should print 'foo'
How do I do the magic to get the name of the method which methodcaller is calling?
It is, but you need to dig into the C internals (not a recommended solution):
Note that this only works on CPython and is not particularly beautiful. But if this is the only solution available, it’s better than nothing.