Message362256
Currently within the ast module, `dump` generates a string representation of the AST for example,
>>> ast.dump(node)
'Module(body=[], type_ignores=[])'
The proposed enhancement would provide a complementary function, `dump_json` as in a json representation of the ast.
This would be useful for those who would like to benefit from the utilities of the json module for formatting, pretty-printing, and the like.
It would also be useful for those who want to serialize the AST or export it in a form that can be consumed in an other programming language.
A simplified example,
>>> import ast
>>> node = ast.parse('')
>>> ast.dump_json(node)
{'Module': {'body': [], 'type_ignores': []}}
A simplified example of using `ast.dump_json` with the json module,
>>> import json
>>> json.dumps(ast.dump_json(node))
'{"Module": {"body": [], "type_ignores": []}}' |
|
Date |
User |
Action |
Args |
2020-02-19 06:23:22 | sparverius | set | recipients:
+ sparverius |
2020-02-19 06:23:22 | sparverius | set | messageid: <1582093402.26.0.349380477656.issue39686@roundup.psfhosted.org> |
2020-02-19 06:23:22 | sparverius | link | issue39686 messages |
2020-02-19 06:23:22 | sparverius | create | |
|