Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with Python 3.10 and 3.11 documentation on @staticmethod decorator #129285

Closed
journpy opened this issue Jan 25, 2025 · 2 comments
Closed
Labels
docs Documentation in the Doc dir

Comments

@journpy
Copy link

journpy commented Jan 25, 2025

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.

@journpy journpy added the docs Documentation in the Doc dir label Jan 25, 2025
@journpy journpy closed this as completed Jan 25, 2025
@hugovk
Copy link
Member

hugovk commented Jan 25, 2025

Thanks for the report.

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.

We usually only make docs changes for Python versions in the bugfix phase (3.12-3.13) and rarely for those in the security-only phase (3.9-3.11), which is why the fix for the linked duplicate was only backported as far as 3.12.

https://devguide.python.org/versions/

@journpy
Copy link
Author

journpy commented Jan 25, 2025

Ok got it. Thank you for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
Status: Todo
Development

No branches or pull requests

2 participants