aleaxit at yahoo.com
Sat May 12 17:47:33 CEST 2001
"Michael Hudson" <mwh at python.net> wrote in message
news:m3d79eraqw.fsf at atrus.jesus.cam.ac.uk...
> James_Althoff at i2.com writes:
> > Does anyone know what the "class" argument -- arg 3 -- to
> > new.instancemethod is for?
> It doesn't seem to serve any "real" purpose other than documentation.
*blink*... come again...?
>>> import new
>>> class A: pass
>>> class B: pass
>>> def f(*args): print 'f',args
f (<__main__.A instance at 007B1E2C>,)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: unbound method must be called with class instance 1st argument
That doesn't seem a case of "no real purpose other than documentation"
to me... when I use new.instancemethod to generate an unbound method,
I _do_ have to tell it what class it is a method of, and far from being just
a tidbit for documentation it will be checked at runtime, raising TypeError
if used inappropriately.
More information about the Python-list