new.instancemethod

Michael Hudson mwh at python.net
Sun May 13 07:40:36 EDT 2001


"Alex Martelli" <aleaxit at yahoo.com> writes:

> "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...?
[snip]
> >>> fb(a)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: unbound method must be called with class instance 1st argument

Oops!  Blame an inaccurate grep for missing that.

> 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.

This check has sometimes struck me as unpythonically draconian.  Would
bad things happen if it was just removed?  Maybe, but I can't think of
any right now.

Cheers,
M.

-- 
  Well, yes.  I don't think I'd put something like "penchant for anal
  play" and "able to wield a buttplug" in a CV unless it was relevant
  to the gig being applied for...
                                 -- Matt McLeod, alt.sysadmin.recovery



More information about the Python-list mailing list