Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83238
| References | <54AA408F.4080101@harvee.org> <54AA5ABC.4020103@wielicki.name> |
|---|---|
| Date | 2015-01-05 23:24 +1100 |
| Subject | Re: need some guidance on Python syntax smart editor for use with speech recognition |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.17393.1420460678.18130.python-list@python.org> (permalink) |
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 comp.lang.python | Previous | Next | Find similar | Unroll thread
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
csiph-web