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.1.2.tar.gz
(4.3 kB
view details)
Built Distribution
File details
Details for the file pprintast-1.1.2.tar.gz
.
File metadata
- Download URL: pprintast-1.1.2.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb73181a393d5f96b5d702f762e18cb97771dca7873d51153abff7e3bafdddf3 |
|
MD5 | 149a9765a745ee240d41095711475696 |
|
BLAKE2b-256 | 60b1e5b506ce8cf3068547748b4c6c061e929ce79c25e11a10140ff2970e79b2 |
File details
Details for the file pprintast-1.1.2-py3-none-any.whl
.
File metadata
- Download URL: pprintast-1.1.2-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 924ca1c2fa68d30982974ae004eafaf7357a47f578cd29399f19cdbd09d0be8b |
|
MD5 | e34a894c97ebd63626cbc2999c636e2e |
|
BLAKE2b-256 | d6eff8260d78e3be5985083f9caee386e39de3e1ee87f265b052f3e2d763fdf6 |