Does Python have Class methods

Alex Martelli aleaxit at yahoo.com
Tue May 8 15:00:02 EDT 2001


"Aahz Maruch" <aahz at panix.com> wrote in message
news:9d946l$6m1$1 at panix2.panix.com...
> In article <3af80f95.73151117 at News.CIS.DFN.DE>,  <costas at meezon.com>
wrote:
> >
> >Does Python support the concept of class methods (as opposed to
> >instance methods)? If not is there a suggested way of doing this?
>
> The standard answer is to put the class (e.g. "foo") into its own module
> (e.g. "foo.py") and use module-level functions.

Right, but that supports "static methods" a la C++ rather than "class
methods" a la Smalltalk.  Another alternative for "static methods" is at
http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/52304, for
example.  Thomas Heller has also put up a Cookbook recipe, at
http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/52311,
which exemplifies how to support "real" (Smalltalk-ish) class methods.


Alex






More information about the Python-list mailing list