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

Terry Reedy tjreedy at udel.edu
Tue Jun 28 19:58:54 CEST 2011

On 6/28/2011 11:35 AM, Michael Foord wrote:
> On 28/06/2011 16:23, Terry Reedy wrote:

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

Before 2.2, these were the only methods.

> So what is the difference between "Instance method" and "Method" above?
> Is it just that "Method" is broader and includes class methods

Since 2.2, yes. The current glossary entry starts

"method A function which is defined inside a class body."

This includes 'staticmethods', but as I have said, I think that is a 
mistake. Static methods are functions without special method treatment. 
A class staticmethod function act the same as any other function.
Also, 'defined inside' is not necessary.

I would change the above to "A function that get bound to a instance or 
class when called as an attribute of the instance or class. Methods are 
usually defined inside a class body."

> and bound methods?

The result of accessing an instance or class method via an instance or 
class. Accessing a static method does not create a bound method. Bound 
methods are usually anonymous and ephemeral, being used for one call and 
then deleted.

> If anyone said "instance method" to me I would assume they meant bound
> method. (A normal method fetched from an instance.)

Instance methods are the 'permanent' class function attributes, not the 
ephemeral object that implements a.b(c). Bound methods would be an 
implementation detail, except that a.b has to evaluate to something and 
saving bound methods is quite handy when calling a method or methods 
repeatedly on the same instance.

Functools.partial is a generalization of bound methods, which were 
Python's first (special-case) implementation of the partial function 
idea. Leaving out implementation details, if b is a function attribute 
of type(a), 'a.b' is an abbreviated way of writing 
'functools.partial(type(a).b,a)' (and yes, I have tested an example of 

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

Terry Jan Reedy

More information about the Python-Dev mailing list