new.instancemethod as a form of partial()

bonono at bonono at
Sun Jan 22 00:54:12 EST 2006

I came across this while searching for a way to DIY partial(), until it
is available in 2.5

However, when trying for the following, it doesn't work and is
wondering if it is a bug or intended :

>>> import operator
>>> import new
>>> new.instancemethod(operator.is_,None,object)(None)

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in -toplevel-
TypeError: is_ expected 2 arguments, got 1
>>> new.instancemethod(operator.is_,False,object)(False)

So it seems that instancemethod() don't like "None" as the instance.

More information about the Python-list mailing list