Closed junjie666666 closed 4 years ago
Formatting info is not stored in AST, it isn't possible to reconstruct original indentation or extra lines.
Not a bug IMO, just using a wrong tool for the job.
Thank you for the report! Looking at this issue again, now I agree with what @esupoff said. astor tries to reformat the input to be PEP 8 compatible. So, in theory, it's possible to get the original formatting only if it follows astor's not-so-great PEP 8 formatting rules.
I meet a problem. when I read data from
test_astor.py
,thento_source()
byastor
, the result get wrong ‘\n’. This problem may affect my data analysis.source data file
test_astor.py
is:I read data by ast and to_source, code is:
but the result is wrong '\n' in save_astor.py: