Skip to main content

nicely

Python Fancy Printer

Abstract

The nicely package is yet another 'pretty printer'.

It is meant to:

  • have a readable and consistent output.

    • Nested levels are indented. (the indentation string is configurable (4 spaces by default))
    • The sequences and the mapping keys are sorted. (can be disabled)
    • Mapping keys are padded. (so the values are aligned)
    • The data types may be shown. (disabled by default)
  • be simple to use.

    • Only one class is required.
    • Convinience functions are also provided.
  • be extensible

    • If the provided support for standard types doesn't suit your need, it's easy to modify it.
    • Any object can easaly be supported.
  • be able to handle large data structure.

    • Sequences, mappings, strings and multi-lines can be truncated as needed.
    • Mapping items can be omitted based on regex.

Usage

There are several ways to use nicel.

The Printer class:

from nicely import Printer

p = Printer()
p.print(some_data_structure)

The Printer.print method sends a formatted representation of its argument to a file-like destination (stdout by default).

The dump function:

from nicely import dump

dump(some_data_structure)

The dump function uses the Printer class to 'dump' its argument on stdout as well as to a file ('nicely.dump' by default).

The format function:

from nicely import format

string = format(some_data_structure)

The format function uses the Printer class to get a string representation of an object.

Data Types support

There are 2 ways for an object to be "printable" / "dumpable":

The Formatter class

The Printer class needs one Formatter for each supported data type (exept for string).

A set of default Formatter is provided by the formatters module for Python's builtin types and should be good enough for most purposes.

These formatters can be modified or extended at will to support new types or modify the output for existing ones.

The print method

Any object can become 'printable' by implementing the print method which will call the Printer's methods in appropriate ways.

Installation

$ pip install nicely

Metadata

Release files for nicely 0.2542.0

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

Source distribution (sdist)

Source distribution for nicely 0.2542.0
File Size Uploaded Provenance
nicely-0.2542.0.tar.gz 10.9 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 20.1 kB

Release files / nicely-0.2542.0.tar.gz

Download URL nicely-0.2542.0.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
80b9fe12ec24380767c6988e756920dd5e71e72825da4d8c760ba12395948973
BLAKE2b-256 checksum
How to use checksums
20b9e6e533d04bc7cdd138985b0fbbbbd6c26a6960b5ae57118e9bb47799baa7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / nicely-0.2542.0-py3-none-any.whl

Download URL nicely-0.2542.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1b489bb9ae4ecba45ee225ad9b88cfd4b6fa9b8b01774281c063c9a51461268
BLAKE2b-256 checksum
How to use checksums
19c5078c1ea401cbfcf09b76708579a7d2abda7df45fbd2cfa4b6b618defa1c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Security for nicely 0.2542.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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