new.instancemethod

James_Althoff at i2.com James_Althoff at i2.com
Thu May 10 16:28:35 EDT 2001


Does anyone know what the "class" argument -- arg 3 -- to
new.instancemethod is for?

>>> new.instancemethod.__doc__
'Create a instance method object from (FUNCTION, INSTANCE, CLASS).'

Although it is mandatory, it doesn't seem to serve any purpose in the
simple example below.

C:\>python
Python 2.0b1 (#4, Sep  7 2000, 02:40:55) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> import new
>>> class Spam: pass
...
>>> class Eggs: pass
...
>>> def whoami(self): print self
...
>>> s = Spam()
>>> s.whoami = new.instancemethod(whoami,s,Spam)
>>> s.whoami()
<__main__.Spam instance at 008090CC>
>>> s.whoami = new.instancemethod(whoami,s,Eggs)
>>> s.whoami()
<__main__.Spam instance at 008090CC>
>>>

Thanks,

Jim





More information about the Python-list mailing list