A AST pretty printer for python.
Project description
pprintast
An AST (abstract syntax tree) pretty printer for Python 🐍.
Installation
$ pip install pprintast
Usage
usage: pprintast.py [-h] [-a] [-c cmd] [-m mode] [-t] [-v] [file]
A pretty-printing dump function for the ast module. The code was copied from the ast.dump function
and modified slightly to pretty-print.
positional arguments:
file program passed in as file
optional arguments:
-h, --help show this help message and exit
-a, --attributes include attributes such as line numbers and column offsets
-c cmd, --command cmd program passed in as string
-m mode, --mode mode compilation mode (choices: exec, eval, single) (default: exec)
-t, --terse terse output by disabling field annotations
-v, --version show program's version number and exit
Script
Pretty print AST from a file using the pprintast CLI.
$ pprintast "./path/to/script.py"
Pretty print AST from a string using the pprintast CLI.
$ pprintast -c "lambda a: a**2"
Module
Pretty print AST from a string using the pprintast module.
# 1. import the "pprintast" function.
from pprintast import pprintast as ppast # OR: from pprintast import ppast
# 2. pretty print AST from a "string".
exp = "lambda a: a**2"
ppast(exp)
License
MIT © Travis Clarke
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pprintast-1.2.0.tar.gz
(4.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pprintast-1.2.0.tar.gz.
File metadata
- Download URL: pprintast-1.2.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5621e5d8db49a0725a539bbbb2b5757155e07d72bc14c771ea96ea089faf31e
|
|
| MD5 |
ab3b2eeea1e94e698f550f20b1afc087
|
|
| BLAKE2b-256 |
1dd6e9a579fdc2609a376baa561bdb2e86d1c946ff0ad90dd87e72592a113d76
|
File details
Details for the file pprintast-1.2.0-py3-none-any.whl.
File metadata
- Download URL: pprintast-1.2.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5447c14c16f2b92fde79a23e51df9763e026b85dccaa79764fb638047b4ae163
|
|
| MD5 |
83ab180273f2e3402371d600b8f1d8e3
|
|
| BLAKE2b-256 |
ef79af7ad8dadedd6e126a280c7abd779b9b9a282f773e1888f0eb9d1f1a2cdb
|