[Python-Dev] Issue10403 - using 'attributes' instead of members in documentation

Terry Reedy tjreedy at udel.edu
Tue Jun 28 17:23:33 CEST 2011


On 6/28/2011 7:51 AM, R. David Murray wrote:

> Also, instances can have methods as instance attributes.

Functions that are instance attributes do not act like methods 
(instance.func() does not automagically turn instance in the first arg 
of func) and have never, to my knowledge, been called methods. In Python 
2, they are not wrapped as methods whereas functions attached to classes 
are.

So-called 'staticmethods' are not really methods either, but are class 
function attributes that are just functions and not treated as methods. 
The decorator that negates normal method treatment could/should have 
been called 'non_method'.

Using 'function' is its generic 'callable' sense ...

Method: a class function attribute that in its intended and normal use 
automagically turns the object it is called on into its first arg. 
'Method' is a useful and needed subcategory of class attribute precisely 
because of this behavior.

Instance method: a class function attribute that is (normally) called on 
instances of the class or subclasses.

Class method: a class function attribute that is (normally) called on 
the class or subclasses.

Bound method: a method that has already has the first-arg object bundled 
with it, so that it can be used as a normal (partial or curried) function.

Except for 'classmethod', which was added later, these have been the 
meanings as I understood them since at least Py 1.4, 15 years ago, and 
they are exactly what one needs to know to use Python. Any object can be 
an attribute. However, function attributes of classes normally get 
special 'method' treatment which alters the meaning of syntax.

-- 
Terry Jan Reedy



More information about the Python-Dev mailing list