parseprint() is used everywhere in docs but is not a part of ast or defined elsewhere
I can't seem to figure out where parseprint()
comes from which makes the docs somewhat confusing. It's helpful to be able to follow along with examples and your own code using functions like this so I would suggest making the function source available.
Comments (6)
-
repo owner -
repo owner - changed status to resolved
Moved the note about the pretty printer to where it is first used.
-
reporter Thanks and sorry I missed it. I blame lackluster search on readthedocs :)
-
repo owner No worries. Maybe it would be easier to find if it referred to
parseprint()
by name rather than just calling it "the pretty printer used in these examples". -
The link above no longer works, do we re-open this issue?
-
repo owner You can find it here: https://bitbucket.org/takluyver/greentreesnakes/src/master/astpp.py
Since Python 3.9, though, the standard library ast.dump() function has done pretty-printing, so you can use
ast.dump(ast.parse('some * code()'), indent=4)
. - Log in to comment
There is a note about it just after the Load/Store/Del nodes at the moment - originally that was the first place it was used, but now we've added a couple more places above. I'll move it up to the first use again.
It comes from this file: https://bitbucket.org/takluyver/greentreesnakes/src/b03baf20aa26d7f21c025a4670a7c1fe9760d2b8/astpp.py?at=default&fileviewer=file-view-default