new.instancemethod

James_Althoff at i2.com James_Althoff at i2.com
Mon May 14 15:38:26 EDT 2001


Alex writes:
><James_Althoff at i2.com> wrote in message
>>
>> 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).'
>
>>>> import new
>>>> def f(self): print self
>...
>>>> class X: pass
>...
>>>> met=new.instancemethod(f,None,X)
>>>> met
><unbound method X.f>
>>>>
>
>Alex

interesting . . . but odd?

>>> import new
>>> def f(self): print self
...
>>> class X: pass
...
>>> met = new.instancemethod(f,None,X)
>>> met
<unbound method X.f>
>>> dir(X)
['__doc__', '__module__']
>>> X.f
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: f

Jim






More information about the Python-list mailing list