-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
Document that return-less user-defined functions return None #126769
Conversation
What would be particularly useful from more experienced Pythonistas would be an indication of whether they think this addition is necessary or a pointer to where this is already documented in the reference documentation (if it is). (And if it's not already documented somewhere, confirmation that it is actually true!) ETA: I see it appears in the description of None. |
Tutorial https://docs.python.org/3/tutorial/controlflow.html#defining-functions has a mention that the function without return returns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. The clarification sentence is short and doesn't blow up the paragraph.
Do we want to backport this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes good sense to me. I've made a small working suggestion to be a bit more precise.
I think backporting makes sense.
Co-authored-by: Carol Willing <[email protected]>
Thanks @jmarshall for the PR, and @asvetlov for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
…H-126769) (cherry picked from commit e0692f1) Co-authored-by: John Marshall <[email protected]> Co-authored-by: Andrew Svetlov <[email protected]> Co-authored-by: Carol Willing <[email protected]>
GH-126822 is a backport of this pull request to the 3.13 branch. |
…H-126769) (cherry picked from commit e0692f1) Co-authored-by: John Marshall <[email protected]> Co-authored-by: Andrew Svetlov <[email protected]> Co-authored-by: Carol Willing <[email protected]>
GH-126823 is a backport of this pull request to the 3.12 branch. |
…H-126769) (#126823) Document that return-less user-defined functions return None (GH-126769) (cherry picked from commit e0692f1) Co-authored-by: John Marshall <[email protected]> Co-authored-by: Andrew Svetlov <[email protected]> Co-authored-by: Carol Willing <[email protected]>
…H-126769) (#126822) Document that return-less user-defined functions return None (GH-126769) (cherry picked from commit e0692f1) Co-authored-by: John Marshall <[email protected]> Co-authored-by: Andrew Svetlov <[email protected]> Co-authored-by: Carol Willing <[email protected]>
I hunted through Calls, Function definitons, and Execution model, but did not spot any text actually specifying that
None
is returned by user-defined functions that fall off the end of their code block without encountering areturn
statement.This adds such text to the description of return values in the Calls section, which IMHO is the most likely place readers would look for it.
📚 Documentation preview 📚: https://cpython-previews--126769.org.readthedocs.build/