Skip to content

Bare yield's behaviour undocumented #100201

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

Closed
pochmann opened this issue Dec 12, 2022 · 3 comments
Closed

Bare yield's behaviour undocumented #100201

pochmann opened this issue Dec 12, 2022 · 3 comments
Labels
docs Documentation in the Doc dir

Comments

@pochmann
Copy link
Contributor

pochmann commented Dec 12, 2022

def g():
    yield

print(next(g()))

That prints None, but the Yield expressions documentation doesn't say so. It only talks about "returning the value of expression_list to the generator’s caller", but doesn't say that None gets returned if the optional expression_list isn't given.

Maybe it's stated in the PEPs referenced at the end, but I think one shouldn't have to look that far. It should be right there in the documentation.

Linked PRs

@pochmann pochmann added the docs Documentation in the Doc dir label Dec 12, 2022
@ramvikrams
Copy link
Contributor

If __next__() is used (typically via either a for or the next() builtin) then the result is None, this line is there in the doc so by it is specified when using next() the result will be None.

@pochmann
Copy link
Contributor Author

No. That's about the value getting into the generator (None when using __next__, or the sent value when using send). I'm talking about the value getting out of the generator.

@ramvikrams
Copy link
Contributor

ramvikrams commented Dec 19, 2022

oh! thanks, i'll do the change then

kumaraditya303 pushed a commit that referenced this issue Jan 1, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jan 1, 2023
…honGH-100416)

(cherry picked from commit 1aab269)

Co-authored-by: ram vikram singh <[email protected]>
Co-authored-by: C.A.M. Gerlach <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jan 1, 2023
…honGH-100416)

(cherry picked from commit 1aab269)

Co-authored-by: ram vikram singh <[email protected]>
Co-authored-by: C.A.M. Gerlach <[email protected]>
miss-islington added a commit that referenced this issue Jan 1, 2023
(cherry picked from commit 1aab269)

Co-authored-by: ram vikram singh <[email protected]>
Co-authored-by: C.A.M. Gerlach <[email protected]>
miss-islington added a commit that referenced this issue Jan 1, 2023
(cherry picked from commit 1aab269)

Co-authored-by: ram vikram singh <[email protected]>
Co-authored-by: C.A.M. Gerlach <[email protected]>
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
None yet
Development

No branches or pull requests

3 participants