Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-86482: Document assignment expression need for ()s#23291

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JelleZijlstra merged 8 commits intopython:mainfromterryjreedy:walrus
Oct 6, 2022

Conversation

terryjreedy
Copy link
Member

@terryjreedyterryjreedy commentedNov 15, 2020
edited
Loading

The list should cover most places where an assignment sub-expression
must be wrapped in parentheses. Judging from the statement docs,
only a couple of statements do not require that they be wrapped.

The list should cover most places where an assignment sub-expressionmust be wrapped in parentheses. Judging from the statement docs,only a couple of statements do not require that they be wrapped.
@lysnikolaou
Copy link
Member

This PR probably needs to be updated to reflect the recent changes introduced in#23317 and#23319. Sorry@terryjreedy!

@terryjreedy
Copy link
MemberAuthor

These are changes I hoped to be able to make ;-). I will add the new in 3.10 item for indexes.

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actionsgithub-actionsbot added the staleStale PR or inactive for long period of time. labelDec 18, 2020
Copy link
Member

@JelleZijlstraJelleZijlstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@terryjreedy are you still interested in landing this? A few older comments were never applied.

@terryjreedyterryjreedy removed their assignmentApr 6, 2022
@terryjreedy
Copy link
MemberAuthor

I somehow missed finishing this and would like it updated and merged. The doc is needed; someone just posted code to pydev that was missing required ()s. However, I just discovered that I have been recently de-authorized from merging anything. Jelle, you have been doing great with doc patches, so it would be fine with me if you finished this without waiting for that problem to be fixed.

@JelleZijlstra
Copy link
Member

I have been recently de-authorized from merging anything

Pablo had turned off merges for everyone during the 3.11.0a7 release, but merges are allowed now again.

@JelleZijlstraJelleZijlstra self-assigned thisApr 6, 2022
@serhiy-storchakaserhiy-storchaka added needs backport to 3.10only security fixes needs backport to 3.11only security fixes and removed needs backport to 3.9only security fixes labelsMay 20, 2022
@github-actionsgithub-actionsbot removed the staleStale PR or inactive for long period of time. labelJul 31, 2022
Copy link
Member

@JelleZijlstraJelleZijlstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This looks good to me now. I'll merge it in a few days unless other people on the PR have more feedback.

@gvanrossum
Copy link
Member

I'm fine with documenting this more precisely, and the wording here looks fine. However, I don't have the time to review the facts -- I hope that Lysandros and Jelle can make sure that the claim made in the text is true (or as close to true as reasonable without spelling out the entire grammar).

@@ -1766,6 +1766,12 @@ Or, when processing a file stream in chunks:
while chunk := file.read(9000):
process(chunk)

Assignment expressions must be surrounded by parentheses when used
as sub-expressions in slicing, conditional, lambda,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Unparenthesized assignment expressions in slices were implemented in#23317, so they are allowed since 3.10. Also, assignment expression need to parenthesized inassert andwith statements.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Unparenthesized walruses are allowed in index expressions but not slices. This is current 3.12:

>>> x[y:=3]Traceback (most recent call last):  File "<stdin>", line 1, in <module>NameError: name 'x' is not defined>>> x[y:=3:z:=4]  File "<stdin>", line 1    x[y:=3:z:=4]          ^SyntaxError: invalid syntax

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Correct! I mixed up indexes/slices. Sorry!

@JelleZijlstraJelleZijlstra merged commit2b5f136 intopython:mainOct 6, 2022
@miss-islington
Copy link
Contributor

Thanks@terryjreedy for the PR, and@JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-97986 is a backport of this pull request to the3.11 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.11only security fixes labelOct 6, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestOct 6, 2022
…-23291)Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>(cherry picked from commit2b5f136)Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
@bedevere-bot
Copy link

GH-97987 is a backport of this pull request to the3.10 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.10only security fixes labelOct 6, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestOct 6, 2022
…-23291)Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>(cherry picked from commit2b5f136)Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
@Brando753Brando753mannequin mentioned this pull requestOct 6, 2022
miss-islington added a commit that referenced this pull requestOct 6, 2022
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>(cherry picked from commit2b5f136)Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
miss-islington added a commit that referenced this pull requestOct 6, 2022
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>(cherry picked from commit2b5f136)Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
carljm added a commit to carljm/cpython that referenced this pull requestOct 6, 2022
* main:fixespythongh-96078: os.sched_yield release the GIL while calling sched_yield(2). (pythongh-97965)pythongh-65961: Do not rely solely on `__cached__` (pythonGH-97990)pythongh-97850: Remove the open issues section from the import reference (python#97935)  Docs: pin sphinx-lint (pythonGH-97992)pythongh-94590: add signatures to operator itemgetter, attrgetter, methodcaller (python#94591)  Add Pynche's move to the What's new in 3.11 (python#97974)pythongh-97781: Apply changes from importlib_metadata 5. (pythonGH-97785)pythongh-86482: Document assignment expression need for ()s (python#23291)pythongh-97943: PyFunction_GetAnnotations should return a borrowed reference. (python#97949)pythongh-94808: Coverage: Test that maximum indentation level is handled (python#95926)
carljm added a commit to carljm/cpython that referenced this pull requestOct 8, 2022
* main:pythonGH-97002: Prevent `_PyInterpreterFrame`s from backing more than one `PyFrameObject` (pythonGH-97996)pythongh-97973: Return all necessary information from the tokenizer (pythonGH-97984)fixespythongh-96078: os.sched_yield release the GIL while calling sched_yield(2). (pythongh-97965)pythongh-65961: Do not rely solely on `__cached__` (pythonGH-97990)pythongh-97850: Remove the open issues section from the import reference (python#97935)  Docs: pin sphinx-lint (pythonGH-97992)pythongh-94590: add signatures to operator itemgetter, attrgetter, methodcaller (python#94591)  Add Pynche's move to the What's new in 3.11 (python#97974)pythongh-97781: Apply changes from importlib_metadata 5. (pythonGH-97785)pythongh-86482: Document assignment expression need for ()s (python#23291)pythongh-97943: PyFunction_GetAnnotations should return a borrowed reference. (python#97949)
mpage pushed a commit to mpage/cpython that referenced this pull requestOct 11, 2022
…3291)Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
pablogsal pushed a commit that referenced this pull requestOct 22, 2022
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>(cherry picked from commit2b5f136)Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
@terryjreedyterryjreedy deleted the walrus branchDecember 17, 2023 00:04
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@JelleZijlstraJelleZijlstraJelleZijlstra approved these changes

@gvanrossumgvanrossumgvanrossum left review comments

@lysnikolaoulysnikolaoulysnikolaou left review comments

Assignees

@JelleZijlstraJelleZijlstra

Labels
docsDocumentation in the Doc dir
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

10 participants
@terryjreedy@lysnikolaou@JelleZijlstra@gvanrossum@miss-islington@bedevere-bot@ambv@serhiy-storchaka@the-knights-who-say-ni@ezio-melotti

[8]ページ先頭

©2009-2025 Movatter.jp