"{0.myattribute}".format already a related method for the string object ( "{0.myattribute}" ). Therefore, when the calling code tries to find up, say, x.__repr__ (where x is an instance of SimpleClass ), Python finds the __repr__ SimpleClass attribute, but then cannot recognize it as the SimpleClass method - the handle protocol is not executed (the string method does not have the __get__ attribute) .
It seems that in 3.4, using lambda will work, although I could swear that in previous versions it was a real feature. functools.partial will not work. But you should still use a real function. Sorry, this is not as dry as you would like.
source share