Is it bad form to call a classmethod as a method from an instance? Is it bad form to call a classmethod as a method from an instance? python python

Is it bad form to call a classmethod as a method from an instance?


If you are tempted to call a class method from an instance you probably don't need a class method.

In the example you gave a static method would be more appropriate precisely because of your last remark (no self/cls interaction).

class C(object):    @staticmethod    def f(x):       return x + x

this way it's "good form" to do both

c = C()c.f(2)

and

C.f(2)


I don't recall using a classmethod like this from outside the class, but it is certainly ok for an instance method to call a classmethod on itself (e.g. self.foo() where foo is a classmethod). This makes sure that inheritance acts as expected, and will call .foo() in the right subclass instead of the base class.


It's mainly just confusing looking. If I were using your class and saw this, it would make me wonder what other surprises are in there, it just looks like bad design.

Is there a reason it's not just a staticmethod?