A static method can be called either on the class (such as
C.f()) or on an instance (such asC().f()). Moreover, they can be called as regular functions (such asf()).
Could someone elaborate on the bold part of the extract from the documentation for Python static methods?
Reading this description one would expect to be able to do something like this:
class C: @staticmethod def f(): print('f') def g(self): f() print('g') C().g() But this generates:
NameError: name 'f' is not defined My question is not about the use-cases where the static method call is name-qualified either with an instance or a class name. My question is about the correct interpretation of the bold part of the documentation.
fis in scope." E.g. you could callf()within theclassdefinition.