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] [-v] [-c cmd] [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(s) passed in as file
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-c cmd, --command cmd program passed in as string
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-0.0.2.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for pprintast-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7de14f5424297f7c2508d93d4e0db39a8b5b797c53bc865d1a2ee0b961df34d3 |
|
MD5 | 745376f070f6833f63c118c3332d243b |
|
BLAKE2b-256 | fff442c4815e5473615bdcc799ca3a182e64046d1b2b2fbccea7e311ba2ac9ac |