I was asked during an interview what is the difference between the following two ways to access a class' attribute:
class Klass:
x = 10
@staticmethod
def foo():
return Klass.x
@classmethod
def bar(cls):
return cls.x
PS: I know the difference between classmethod
and staticmethod
.