way to define static method
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Mon Aug 20 14:41:00 EDT 2007
Eric CHAO a écrit :
> Thanks a lot.
>
> Because I found a solution about static method from
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52304
This is a largely outdated recipe (while it may be usefull if you have
to write code for an old Python version).
> And that's a little bit difficult to understand.
This of course require some knowledge of Python's internals. But unless
you have to deal with older Python versions, you don't have to care
about this - just use:
class MyClass(object):
@staticmethod
def my_static_method(name):
print name
FWIW, there's not much use for staticmethods in Python - usually, a
plain function is what you want.
More information about the Python-list
mailing list