This staticmethod()
function returns a static method for function.
staticmethod(function)
Here,
Note: A static method does not receive an implicit first argument. When a function decorated with @staticmethod is called, we don’t pass an instance of the class to it (as we normally do with methods). This means we can put a function inside a class but we can’t access the instance of that class (this is useful when your method does not use the instance).
>>> class Func1:
... @staticmethod
... def subfunc():
... print 'hello'
...
>>> Func1.subfunc
<function subfunc at 0x00DBC1B0>
>>> Func1().subfunc
<function subfunc at 0x00DBC1B0>
>>> Func1.subfunc()
hello
>>> Func1().subfunc()
Hello
>>> # this example uses obsolete no-decorator syntax
>>> class Func1:
... def subfunc():
... print 'hello'
... subfunc = staticmethod(subfunc)
...
>>> Func1.subfunc
<function subfunc at 0x00DBC270>
>>> Func1().subfunc
<function subfunc at 0x00DBC270>
>>> Func1().subfunc()
hello
>>> Func1.subfunc()
hello*