Skip to main content

A AST pretty printer for python.

Project description


PyPi release PyPi versions Downloads Documentation Status

An AST (abstract syntax tree) pretty printer for Python 🐍.

Check out the pprintast docs


$ pip install pprintast


usage: [-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


Pretty print AST from a file using the pprintast CLI.

$ pprintast "./path/to/"

Pretty print AST from a string using the pprintast CLI.

$ pprintast -c "lambda a: a**2"


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"




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.

Files for pprintast, version 1.2.1
Filename, size File type Python version Upload date Hashes
Filename, size pprintast-1.2.1-py3-none-any.whl (6.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pprintast-1.2.1.tar.gz (4.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page