| I've been doing a lot of reading about static methods in Python,

and possibly getting over-confused by the minutia of the CPython
implementation, as well as by the misnomer.  Conceptually, a 'static 
method'
is a function attribute of a class that is to be used as a function and not
as a method (where 'methods', in Python, get semi-magic first parameters).
Note that function attributes of instances are also just functions, and not
methods (which sometimes fools people), as are function attributes of
modules.

| not exactly sure what they are useful for or why they were introduced.

Completeness (as RK said), occasional real usefulness, and for C++&Java
programmers.  Python did fine without them.

| As near as I can see it, static methods are object methods that act just
| like functions.

Almost: class function/method, depending on your meaning of method.  See
above.

|Er. I always thought that object methods *were* functions,
| except they had some runtime magic that passed the object itself as the
| first argument.

Substitute class for object and class or instance for object itself and you
have it.  The runtime magic is a minor abbreviation but its major purpose 
is
inheritance.

Now you can more on to something more useful like metaclasses or decorators
;-).

Terry J. Reedy



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to