Static class methods
Daniel Klein
danielk at aracnet.com
Tue Mar 6 09:10:30 EST 2001
On Mon, 5 Mar 2001 20:40:29 -0800, "Alex Shindich" <alex at shindich.com> wrote:
>There are indeed many ways to simulate the behavior. But shouldn't such a
>strong OOP language like Python have support for static methods?
It's not really necessary to be honest. The approach outlined in TQJB was just
a 'suggestion' cos you seemed 'distressed' you couldn't define a class method
associated to a specific class. When I need such a method I simply define it
as a 'top level' function in the module and call if from the class instances.
The fact that it isn't 'bound' to a particular class does not bother me. That's
what doc strings are for. :-) On occasion there are situations where one of
these 'top level' methods becomes useful to more than one class in the module
and then I reap the benefits of reuse.
Daniel Klein
Portland OR USA
More information about the Python-list
mailing list