[Python-Dev] Customizing the binding of attributes

Guido van Rossum guido@python.org
Fri, 24 Aug 2001 15:49:42 -0400

> I wasn't talking about your getset object (which is already mentioned
> in the PEP), I was thinking of an 'instancemethod' object,
> which would accept any callable (for example a *function*
> implemented in an extension module), and convert it into an unbound
> or bound method when retrieved from a class or an instance.
> Something like
> class instancemethod(object):
>     def __init__(self, callable):
>         self.callable = callable
>     def __get__(self, inst, klass=None):
>         import new
>         return new.instancemethod(self.callable, inst, klass)
> only faster ;-)

I believe the (unbound) instance method type itself has this
functionality, except it has no working constructor.  I will fix that
(not today :-).

--Guido van Rossum (home page: http://www.python.org/~guido/)