[Python-ideas] Having unbound methods refer to the classes their defined on
Terry Reedy
tjreedy at udel.edu
Wed Jun 2 05:01:23 CEST 2010
On 6/1/2010 1:36 PM, cool-RR wrote:
> In Python 2.x there was an "unbound method" type. An unbound method
> would have an attribute `.im_class` that would refer to the class on
> which the method was defined.
Actually, I believe it referred to the class through which the function
was accessed. The object in the class __dict__ was still the function.
In both 2.x and 3.x, a function can be an attribute of more than one
class and might not have been defined 'on' any of them.
Right or wrong, I believe it was thought that adding the wrapper was
more of a nuisance than a benefit.
I suppose you could propose that when a function is directly accessed as
a class (as opposed to via an instance, when wrapping as a bound method
is still done), an __access_class__ attribute could be added, but I do
not know if that would even help you. Perhaps a custom metaclass could
be written to do this now (I definitely do not know this for sure).
Terry Jan Reedy
More information about the Python-ideas
mailing list