Add ast.Constant node
Another novelty in Python 3.6 that I missed.... cf https://bugs.python.org/issue26146
Comments (7)
-
repo owner -
reporter Looking again at the issue, it does indeed looks like (at least for now) ast.Constant is generated by an optimizer not directly. So I guess there is no hurry to document it maybe.
-
repo owner It's not a priority, but if you can work out how it fits in with the other nodes, PRs welcome. And kudos for replying so quickly after I let the issue languish for a year!
-
I think it's coming in python-3.8 so we should add it soon.
https://github.com/python/cpython/pull/9445/files
-
repo owner I'm not too concerned by that until Python 3.8 is a bit closer to release, but if you want to make a pull request, go for it. We'll want to document that creating
Constant
nodes works from Python 3.6 (assuming it does!), and the parser gives you them from 3.8. -
repo owner Done in PR
#9and a couple of subsequent cleanup commits. -
repo owner - changed status to resolved
- Log in to comment
It's not immediately obvious to me what code is parsed to a Constant node. I looked at the issue and played around briefly, but I didn't get any
Constant
s (this is in Python 3.6).Maybe it only comes from an optimisation pass that isn't done when parsing code to return an AST?