STINNER Victor added the comment: "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." ---------- nosy: +haypo _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25886> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com