Skip to content

gh-138011: add note about instantiating MyClass with ( ) #138016

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

Conversation

PrinceNaroliya
Copy link
Contributor

@PrinceNaroliya PrinceNaroliya commented Aug 21, 2025

Summary:

This PR adds a clarifying note to the class tutorial section.

  • Emphasizes that writing x = MyClass (without parentheses) does not create an instance.
  • Explains that calling x.f() in this case raises TypeError: missing 1 required positional argument: 'self'.
  • Shows the correct usage: x = MyClass().

Related Issue

Addresses confusion reported in issue #138011.

Verification

  • ✅ Built docs locally with make html
  • ✅ Verified that the new note renders correctly

Screenshot

Screenshot 2025-08-21 100929

📚 Documentation preview 📚: https://cpython-previews--138016.org.readthedocs.build/

Add a note that writing x = MyClass without parentheses will not create
an instance and calling x.f() will raise TypeError. The correct usage
is x = MyClass().
@StanFromIreland
Copy link
Member

Hello, there is already a PR open for this issue: #138014

@StanFromIreland StanFromIreland changed the title Doc: add note about instantiating MyClass with ( ) gh-138011: add note about instantiating MyClass with ( ) Aug 21, 2025
@StanFromIreland
Copy link
Member

Thanks, but I will close in favor of Terry's PR. I suggest you look into some of the other open issues.

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

Successfully merging this pull request may close these issues.

2 participants