2 ms·
@staticmethod is kinda pointless in two ways. One, it has the same effect as @classmethod, except the first argument, so you can always just use @classmethod. T
by Kwpolska 4y ago
@staticmethod is kinda pointless in two ways. One, it has the same effect as @classmethod, except the first argument, so you can always just use @classmethod. Two, you could argue that static methods don’t make much sense in a language which has top-level functions (unlike Java). If something is part of the class but does not make use of the class state and should be usable from outside of the class, then it should be a plain function, not a @staticmethod. (Overzealous linters that suggest @staticmethod when the method could be a function, or when the method is part of some public interface and does not necessarily have to be static in other implementations, are dumb.)