How do I override a staticmethod and keep it static?
In [6]: class Foo(object):
...: @staticmethod
...: def foo(a, b):
...: print a + b
...:
...:
In [7]: Foo.foo
Out[7]: <function foo at 0x86a1a74>
In [8]: class Bar(Foo):
...: def foo(a, b):
...: print a - b
...:
...:
In [9]: Bar.foo
Out[9]: <unbound method Bar.foo>
I’ve tried decorated Bar’s foo with staticmethod and it works. But I have to decorated it everytime I subclass.
That’s how you are supposed to do it. In other programming languages you have to use the
statickeyword everytime, too.