Add ast.Constant node

Issue #9 resolved
Matthieu Dartiailh created an issue

Another novelty in Python 3.6 that I missed.... cf https://bugs.python.org/issue26146

Comments (7)

  1. Thomas Kluyver repo owner

    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 Constants (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?

  2. Matthieu Dartiailh 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.

  3. Thomas Kluyver 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!

  4. Thomas Kluyver 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.

  5. Log in to comment