Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Actually it works in CPython 3.9 too -- it was an easter egg of the PEG parser project.
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.
Ah, another dict-keys-are-sorted situation where it’s an implementation detail in one version and an official documented feature in the next. Not sure if I should weigh the text down with technical correctness here!
I’ll wait to see if someone proposes to replace the whole example with something else that still requires or looks better with backslashes.
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.
I feel like we should give an example with parenthesized with instead. The PEP should reflect the current preferred style, not the past style.
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.
The context is a section about backslashes, not context managers! This is saying that backslashes are generally discouraged, with some exceptions like multiple context managers, which now does not apply.
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.
From the perspective of a "regular" Python user, I suggest just picking whichever makes the more sense to tell users and go with that here.
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.
Sounds good!
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.
Since this section is about backslashes, what about just saying:
the remove the
with
statement example. If you can't find another example that doesn't rely onwith
-statements, then enough said!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.
If I understand correctly, this could potentially happen in any keyword statement with a syntax that incorporated commas to separate arguments that didn't explicitly allow commas:
return
andyield
statements often have commas used within them, but that's because they are used with tuples, not have multiple distinct arguments, so they work finewith
statements were formally fixed in Python 3.10, with an undocumented implementation-dependent fix in Python 3.9import
statements, unlikefrom
statements, don't allow parens for continuation, but that's deliberate to not encourage users to group too many top-level imports into the same import statement, and thus would be very anti-PEP 8 anywayI think that's everything, though I'm just a regular Pythonista and not a BDFL or FLUFL like you folks, so I could easily have missed something :)
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.
Yeah, I'm just gonna merge it as-is.
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.
I wanted to see how it looks like with Adam’s suggestion (show recommended example first, in the paragraph just before that mentions parens, then keep backslash example with amended text), but I didn’t have time to do that immediately and the discussion did not wait until I came back 🙂