On 28/06/2011 16:23, Terry Reedy wrote: > 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. > So what is the difference between "Instance method" and "Method" above? Is it just that "Method" is broader and includes class methods and bound methods? If anyone said "instance method" to me I would assume they meant bound method. (A normal method fetched from an instance.) All the best, Michael > 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. > -- http://www.voidspace.org.uk/ May you do good and not evil May you find forgiveness for yourself and forgive others May you share freely, never taking more than you give. -- the sqlite blessing http://www.sqlite.org/different.html
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4