Skip to main content

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',
	}

terminal output

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 objects

    it splits too long lines into indented blocks by syntax markers (such as {}()[], etc)

    be careful: as print, nprint uses the string conversion str(obj) to convert an object passed, if you want to use the string representation, then you'll have to pass repr(obj) to nprint or nformat

  • nformat(text, indent=0, width=100) -> str

    split a text into indented lines

  • ncolor(text) -> str

    add color makers for terminals syntax highlighting

  • deformat(text) -> str

    remove formatting of all marker-enclosed text

Metadata

Release files for pnprint 1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pnprint 1.3
File Size Uploaded
pnprint-1.3.tar.gz 5.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pnprint 1.3
File Interpreter ABI Platform
pnprint-1.3-py3-none-any.whl Python 3 none any Details

Total release size: 11.9 kB

Release files / pnprint-1.3.tar.gz

Download URL pnprint-1.3.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5129681f463914137b62f61124a8bda83eef4d31592bea38db569f9189106047
BLAKE2b-256 checksum
How to use checksums
9d73e4b8c7b3f7db0878989ec4fe6735369b1bfc995d676de762d6fe9bc75831
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.11.2 Linux/6.1.0-33-amd64

Release files / pnprint-1.3-py3-none-any.whl

Download URL pnprint-1.3-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
091eced168a39b372895b669f0b960bb8534469641660da20309baa986a60571
BLAKE2b-256 checksum
How to use checksums
07f2f8242cfb6e4d0d9663c4b028034a43f622b1269d0631d2bab3c2ff6b5a97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.11.2 Linux/6.1.0-33-amd64

Release history Release notifications | RSS feed

This release

1.3 This release

2 release files

1.2

2 release files

1.1

2 release files

1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page