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

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to