This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients SilentGhost, benjamin.peterson, brett.cannon, georg.brandl, myronww, ncoghlan, r.david.murray, vstinner
Date 2015-12-16.21:58:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1450303100.03.0.851455531903.issue25886@psf.upfronthosting.co.za>
In-reply-to
Content
"The fact that ast combines strings and does not maintain the original syntax of the document means that original syntax information is lost and a writer walking the abstract syntax tree is unable to reproduce the original syntax of the document."

You should take a look at the RedBaron project which implements a Python parser, provide a high-level representation of the code *and* allow to regenerates the Python code without loosing the indentation, comment, or anything else.

https://redbaron.readthedocs.org/en/latest/

"To achieve this, [RedBaron] is based on Baron a lossless AST for Python that guarantees the operation
fst_to_code(code_to_fst(source_code)) == source_code."
History
Date User Action Args
2015-12-16 21:58:20vstinnersetrecipients: + vstinner, brett.cannon, georg.brandl, ncoghlan, benjamin.peterson, r.david.murray, SilentGhost, myronww
2015-12-16 21:58:20vstinnersetmessageid: <1450303100.03.0.851455531903.issue25886@psf.upfronthosting.co.za>
2015-12-16 21:58:20vstinnerlinkissue25886 messages
2015-12-16 21:58:19vstinnercreate