-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
bpo-39199: Use 'eval' mode for the examples with expression nodes #18828
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
Co-Authored-By: Serhiy Storchaka <[email protected]>
Commit a8b092b moves all examples to use single quotes when possible |
Doc/library/ast.rst
Outdated
| op=USub(), | ||
| operand=Name(id='a', ctx=Load())))], | ||
| type_ignores=[]) | ||
| >>> print(ast.dump(ast.parse('-a', mode='eval'), indent=4)) |
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.
This example should use the "exec" mode.
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.
Could you elaborate on the reason why? The difference between the two trees does not add anything that stands out to me:
>>> print(ast.dump(ast.parse('-a', mode='eval'), indent=4))
Expression(
body=UnaryOp(
op=USub(),
operand=Name(id='a', ctx=Load())))
>>> print(ast.dump(ast.parse('-a', mode='exec'), indent=4))
Module(
body=[
Expr(
value=UnaryOp(
op=USub(),
operand=Name(id='a', ctx=Load())))],
type_ignores=[])
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.
It is an example for the Expr node.
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.
🤦♂️ Whops! Thanks, I clearly need more coffee.
serhiy-storchaka
left a comment
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.
👍
|
Thank you very much @serhiy-storchaka for the awesome review! :) |
|
Thank you for the great improvement of the documentation! |
https://bugs.python.org/issue39199