A drop-in replacement for pprint that's actually pretty
Project description
Installation
$ pip install pprintpp
Usage
pprintpp can be used in three ways:
As a regular module:
>>> import pprintpp >>> pprintpp.pprint(...)
As a command-line program, which will read Python literals from standard in and pretty-print them:
$ echo "{'hello': 'world'}" | pypprint {'hello': 'world'}
To monkeypatch pprint:
>>> import pprintpp >>> pprintpp.monkeypatch() >>> import pprint >>> pprint.pprint(...)
Note: the original pprint will be available with import pprint_original.
Why is it prettier?
Unlike pprint, pprintpp strives to emit a readable, largely PEP8-complient, representation of its input.
Note: pprintpp is still under development, so the format will change and improve over time.
Without printpp:
>>> import pprint >>> import numpy as np >>> pprint.pprint(["Hello", np.array([[1,2],[3,4]])]) ['Hello', array([[1, 2], [3, 4]])] >>> tweet = {'coordinates': None, 'created_at': 'Mon Jun 27 19:32:19 +0000 2011', 'entities': {'hashtags': [], 'urls': [{'display_url': 'tumblr.com/xnr37hf0yz', 'expanded_url': 'http://tumblr.com/xnr37hf0yz', 'indices': [107, 126], 'url': 'http://t.co/cCIWIwg'}], 'user_mentions': []}, 'place': None, 'source': '<a href="http://www.tumblr.com/" rel="nofollow">Tumblr</a>', 'truncated': False, 'user': {'contributors_enabled': True, 'default_profile': False, 'entities': {'hashtags': [], 'urls': [], 'user_mentions': []}, 'favourites_count': 20, 'id_str': '6253282', 'profile_link_color': '0094C2'}} >>> pprint.pprint(tweet) {'coordinates': None, 'created_at': 'Mon Jun 27 19:32:19 +0000 2011', 'entities': {'hashtags': [], 'urls': [{'display_url': 'tumblr.com/xnr37hf0yz', 'expanded_url': 'http://tumblr.com/xnr37hf0yz', 'indices': [107, 126], 'url': 'http://t.co/cCIWIwg'}], 'user_mentions': []}, 'place': None, 'source': '<a href="http://www.tumblr.com/" rel="nofollow">Tumblr</a>', 'truncated': False, 'user': {'contributors_enabled': True, 'default_profile': False, 'entities': {'hashtags': [], 'urls': [], 'user_mentions': []}, 'favourites_count': 20, 'id_str': '6253282', 'profile_link_color': '0094C2'}}
With printpp:
>>> import pprintpp >>> pprintpp.pprint(["Hello", np.array([[1,2],[3,4]])]) [ 'Hello', array([[1, 2], [3, 4]]), ] >>> pprintpp.pprint(tweet) { 'coordinates': None, 'created_at': 'Mon Jun 27 19:32:19 +0000 2011', 'entities': { 'hashtags': [], 'urls': [ { 'display_url': 'tumblr.com/xnr37hf0yz', 'expanded_url': 'http://tumblr.com/xnr37hf0yz', 'indices': [107, 126], 'url': 'http://t.co/cCIWIwg', }, ], 'user_mentions': [], }, 'place': None, 'source': '<a href="http://www.tumblr.com/" rel="nofollow">Tumblr</a>', 'truncated': False, 'user': { 'contributors_enabled': True, 'default_profile': False, 'entities': {'hashtags': [], 'urls': [], 'user_mentions': []}, 'favourites_count': 20, 'id_str': '6253282', 'profile_link_color': '0094C2', }, }
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pprintpp-0.1.1.tar.gz
(5.9 kB
view details)
Built Distribution
File details
Details for the file pprintpp-0.1.1.tar.gz
.
File metadata
- Download URL: pprintpp-0.1.1.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80f7c4eb3dead3ddd10b3b326fb3be1b752ecef13ac986f0672b49f062f3f28e |
|
MD5 | 593b8a1ccea610c8ed340ce7405816ec |
|
BLAKE2b-256 | 9704ce6cfed3243957c43ecd77c3480fd3b3b00a93a5b83f9c32325ef123fc22 |
File details
Details for the file pprintpp-0.1.1-py27-none-any.whl
.
File metadata
- Download URL: pprintpp-0.1.1-py27-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 2.7
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4af74be80329c431a5d67b0e5e1537a1bb92ced42dacbdbb1bb56dab4d6cbdd |
|
MD5 | c2e4991e164f6790c5e8065403cdc8fa |
|
BLAKE2b-256 | c350fa362aa3ead369a6c162a6f14e168467772b355b16453f5b7c65f10dd544 |