Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #66707 > unrolled thread
| Started by | Dan Goodman <dg.gmane@thesamovar.net> |
|---|---|
| First post | 2014-02-19 17:40 +0000 |
| Last post | 2014-02-19 17:40 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Turning an AST node / subnodes into something human-readable Dan Goodman <dg.gmane@thesamovar.net> - 2014-02-19 17:40 +0000
| From | Dan Goodman <dg.gmane@thesamovar.net> |
|---|---|
| Date | 2014-02-19 17:40 +0000 |
| Subject | Re: Turning an AST node / subnodes into something human-readable |
| Message-ID | <mailman.7158.1392831639.18130.python-list@python.org> |
Chris Angelico <rosuav <at> gmail.com> writes: > I'm working with the ast module to do some analysis on Python > codebases, and once I've found what I'm looking for, I want to print > something out. The file name I'm hanging onto externally, so that > works; and the nodes all have a lineno. So far so good. But how do I > "reconstitute" a subtree into something fit for human consumption? I did something like this, feel free to use my code: https://github.com/brian-team/brian2/blob/master/brian2/parsing/rendering.py At the moment, it only works for series of mathematical statements (no control conditions, loops, array notation, etc.), but it would be pretty easy to add those. It also puts too many parentheses in outputted expressions, e.g. 1+2+3 would come back as (1+2)+3, etc. Dan
Back to top | Article view | comp.lang.python
csiph-web