- Notifications
You must be signed in to change notification settings - Fork52
simonpercivall/astunparse
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation


An AST unparser for Python.
This is a factored out version ofunparse found in the Pythonsource distribution; under Demo/parser in Python 2 and under Tools/parserin Python 3.
Basic example:
import inspectimport astimport astunparse# get back the source codeastunparse.unparse(ast.parse(inspect.getsource(ast)))# get a pretty-printed dump of the ASTastunparse.dump(ast.parse(inspect.getsource(ast)))
This library is single-source compatible with Python 2.6 through Python 3.5. Itis authored by the Python core developers; I have simply merged the Python 2.7and the Python 3.5 source and test suites, and added a wrapper. This factoringout is to provide a library implementation that supports both versions.
Added to this is a pretty-printingdump utility function.
The test suite both runs specific tests and also roundtrips much of thestandard library.
Similar projects include:
None of these roundtrip much of the standard library and fail several of the basictests in thetest_unparse test suite.
This library uses mature and core maintained code instead of trying to patchexisting libraries. Theunparse and thetest_unparse modulesare under the PSF license.
Extensions include:
- typed-astunparse: extends astunparse to support type annotations.
- Documentation:http://astunparse.rtfd.org.
- unparses Python AST.
- pretty-prints AST.
About
An AST unparser for Python
Topics
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors10
Uh oh!
There was an error while loading.Please reload this page.