Static class methods

Alex Shindich alex at shindich.com
Mon Mar 5 23:40:29 EST 2001


There are indeed many ways to simulate the behavior. But shouldn't such a
strong OOP language like Python have support for static methods?
"Daniel Klein" <danielk at aracnet.com> wrote in message
news:aqa7at0b6cbqjaq23mli0flmumlp8n6s9s at 4ax.com...
> On Sun, 4 Mar 2001 14:22:10 -0800, "Alex Shindich" <alex at shindich.com>
wrote:
>
> >Just out of my curiosity, have any of you ladies and gentlemen
experienced a
> >need for an equivalent of C++/Java static method?
> >Because I have, but it is impossible add them to Python classes -- all
class
> >methods are treated as instance methods.
>
> The Quick Python Book by Daryl Harms and Kenneth McDonald outlines a way
to
> accomplish this by breaking out the class into its own module and then
define
> the 'class methods' as top-level functions.
>
> myclass.py
>
> def myClassMethod():
> # do some class thing
>
> class Foo:
> def __init__(self):
>                   pass
> def bar(self):
> pass
>
> Daniel Klein
>





More information about the Python-list mailing list