I had a question about the preferred way of calling static and class methods within a class in Python ( >= 2.7).
From this resource Calling method, classmethod, staticmethod in the same Python class, I can understand why it is better to use self
over the class name to call static methods. My question is if it is better to use self
or type(self)
when trying to call static/class methods within a class?
class A:
pass
class B(A):
@staticmethod
def f():
return 5
def g_option1(self):
return type(self).f()
def g_option2(self)
return self.f()