-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Description
I am looking at Python 3.10 and 3.11 docs on @staticmethod
and it says "A static method can be called either on the class (such as C.f()) or on an instance (such as C().f()). Moreover, they can be called as regular functions (such as f())."
Say I have a class with a static method decorator:
class Foo:
@staticmethod
def a_num(*args):
return 'this is a number'
Foo.a_num()
returns 'this is a number'
likewise Foo().a_num()
but just calling a_num()
returns an error saying NameError: name 'a_num' is not defined
. To my understanding, this contradicts the docs which says static methods can be called as regular functions without giving it an instance of the class i.e. f(). Is my understanding correct on this?
I have looked at 3.9 - 3.13 docs and only found this on 3.10 and 3.11. Is this a mistake or am I missing something? Thanks.
Metadata
Metadata
Assignees
Labels
Projects
Status