format and color serialized data strings to make them more human readable
Project description
nprint
This is a module providing convenient functions to format, color and print any string to highlight any contained data structures.
It intends to replace the well known pprint, to format python objects on output
from nprint import nprint
data = {
'name': 'mydict',
'comment': 'this is a dictionnary',
'field': (5, 6),
'long one': [12324232, 53445645645, 'truc', 345345345345345356, (456,45), 'bla bla bla', 'blo blo blo', 'things and so'],
'some text': '/!\\ even content of strings are formated:\n {345, 23, 17, [2,1]} as you see\n',
}
installation
using pip:
pip install pnprint
or copy nprint.py from this repo to any directory you want !
functions provided:
-
nprint(*args, indent=0, color=True, end='\n')the pprint replacement: it works as
print()but works on strings instead of working on already known objectsit splits too long lines into indented blocks by syntax markers (such as
{}()[], etc)be careful: as
print,nprintuses the string conversionstr(obj)to convert an object passed, if you want to use the string representation, then you'll have to passrepr(obj)tonprintornformat -
nformat(text, indent=0, width=100) -> strsplit a text into indented lines
-
ncolor(text) -> stradd color makers for terminals syntax highlighting
-
deformat(text) -> strremove formatting of all marker-enclosed text
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pnprint-1.3.tar.gz.
File metadata
- Download URL: pnprint-1.3.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.11.2 Linux/6.1.0-33-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5129681f463914137b62f61124a8bda83eef4d31592bea38db569f9189106047
|
|
| MD5 |
c91e5de709c844942a5b9900262a94a7
|
|
| BLAKE2b-256 |
9d73e4b8c7b3f7db0878989ec4fe6735369b1bfc995d676de762d6fe9bc75831
|
File details
Details for the file pnprint-1.3-py3-none-any.whl.
File metadata
- Download URL: pnprint-1.3-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.11.2 Linux/6.1.0-33-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
091eced168a39b372895b669f0b960bb8534469641660da20309baa986a60571
|
|
| MD5 |
acba1332438027cbff13efae0bff621f
|
|
| BLAKE2b-256 |
07f2f8242cfb6e4d0d9663c4b028034a43f622b1269d0631d2bab3c2ff6b5a97
|