-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Improve the AST documentation #83380
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
Comments
The AST docs need some love as they can be a bit obscure to someone new to the module. Improvements to be considered in this issue:
|
Would not be better to use mode='eval' for expression nodes? >>> print(ast.dump(ast.parse('123', mode='eval'), indent=4))
Expression(
body=Constant(value=123, kind=None)) |
Agreed! I will prepare a PR soon to simplify the expression examples. |
As you worked much with ast.dump(), what multi-line formatting do you prefer, the current
or with closing brackets on separate lines?
The latter make contain long stairs of closing brackets. |
The first one looks on first inspection "cleaner" but then I tried to look at a random closed bracket/parenthesis like the ones in
value=Constant(value=Ellipsis))])])], and trying to guess where that closes and is confusing to say the least so I think I would prefer the second one as is less "dense". Additionally, I was curious and I have asked several people with different examples and almost everyone prefers the second one, being |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: