new.instancemethod as a form of partial()

bonono at gmail.com bonono at gmail.com
Sun Jan 22 06:54:12 CET 2006


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

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/229472

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-
    new.instancemethod(operator.is_,None,object)(None)
TypeError: is_ expected 2 arguments, got 1
>>> new.instancemethod(operator.is_,False,object)(False)
True

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




More information about the Python-list mailing list