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 details)
Built Distribution
File details
Details for the file pprintast-0.0.2.tar.gz
.
File metadata
- Download URL: pprintast-0.0.2.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d2582995618e649c32db8d36cfc4e63c1e8a5ce8899c9b5406a155ccbfc42d0 |
|
MD5 | 4a4ab32f0e1a4c4297595669220d8e23 |
|
BLAKE2b-256 | ec2fba8d7af948b58ec1f62bf0d46a5eff222f5ad596382ee82041944558d39a |
File details
Details for the file pprintast-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: pprintast-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.6 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.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7de14f5424297f7c2508d93d4e0db39a8b5b797c53bc865d1a2ee0b961df34d3 |
|
MD5 | 745376f070f6833f63c118c3332d243b |
|
BLAKE2b-256 | fff442c4815e5473615bdcc799ca3a182e64046d1b2b2fbccea7e311ba2ac9ac |