Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83238 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2015-01-05 23:24 +1100 |
| Last post | 2015-01-05 23:24 +1100 |
| 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: need some guidance on Python syntax smart editor for use with speech recognition Chris Angelico <rosuav@gmail.com> - 2015-01-05 23:24 +1100
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2015-01-05 23:24 +1100 |
| Subject | Re: need some guidance on Python syntax smart editor for use with speech recognition |
| Message-ID | <mailman.17393.1420460678.18130.python-list@python.org> |
On Mon, Jan 5, 2015 at 8:34 PM, Jonas Wielicki <jonas@wielicki.name> wrote: > As a first iteration, I would try with any editor written in Python. > Are you familiar with the ast[1] module? It could be worth trying to > use this module and perform some kind of pattern matching on the > results to recover the information. An AST parse throws away a lot of information. You can't easily reconstruct the original code from that; at best, you can decompile the AST back into functionally-equivalent source code, but it's not something you want to do as part of editing code. There's an Unparser() in CPython/Tools/parser/unparse.py [1] which is great for visualizing an AST structure, but if you take a .py file, compile it to AST, and then unparse it, you'll end up with something quite different. However, back when I was doing my PEP 463 research, someone suggested looking into the 2to3 parser. I regretfully admit that I have yet to actually do so, but it ought in theory allow source-level transformations with a measure of intelligence. It's not a ready-made solution by any means, but it could be a useful tool. [2] > Hope this helps. I find that topic pretty interesting. Is there > anything I can follow to see progress on this? Likewise! ChrisA [1] https://hg.python.org/cpython/file/tip/Tools/parser/unparse.py [2] http://time-loop.tumblr.com/post/47664644/python-ast-preserving-whitespace-and-comments
Back to top | Article view | comp.lang.python
csiph-web