Skip to main content

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

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

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

pnprint-1.3.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pnprint-1.3-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

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

Hashes for pnprint-1.3.tar.gz
Algorithm Hash digest
SHA256 5129681f463914137b62f61124a8bda83eef4d31592bea38db569f9189106047
MD5 c91e5de709c844942a5b9900262a94a7
BLAKE2b-256 9d73e4b8c7b3f7db0878989ec4fe6735369b1bfc995d676de762d6fe9bc75831

See more details on using hashes here.

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

Hashes for pnprint-1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 091eced168a39b372895b669f0b960bb8534469641660da20309baa986a60571
MD5 acba1332438027cbff13efae0bff621f
BLAKE2b-256 07f2f8242cfb6e4d0d9663c4b028034a43f622b1269d0631d2bab3c2ff6b5a97

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page