Skip to main content

Python pretty formatting package

Project description

PyPformat

tests examples ruff - linter & formatter coverage


Overview

PyPformat is a simple and highly customizable python pretty-formatting package designed as an alternative to the built-in pprint library - PyPformat uses a different, more natural formatting style and provides extensive personalization capabilities, including text colorizing or customized indentation marking, on top of the basic options like compact printing.


The example below demostrates the difference in the default outputs produced by the pprint and PyPformat libraries.

>>> from pprint import pprint
>>> import pformat as pf
>>>
>>> from collections import ChainMap, OrderedDict, defaultdict
>>>
>>> mapping = {
...     "key1": 1,
...     "key2": OrderedDict({"key3": 3, "key4": 4}),
...     "key5": defaultdict(
...         str,
...         {
...             "key6": 6,
...             "a_very_long_dictionary_key7": ChainMap(
...                 {"key10": [10, 11, 12, 13], "key8": 8, "key9": 9}
...             ),
...         },
...     ),
... }
>>>
>>> pprint(mapping)
{'key1': 1,
 'key2': OrderedDict({'key3': 3, 'key4': 4}),
 'key5': defaultdict(<class 'str'>,
                     {'a_very_long_dictionary_key7': ChainMap({'key10': [10,
                                                                         11,
                                                                         12,
                                                                         13],
                                                               'key8': 8,
                                                               'key9': 9}),
                      'key6': 6})}
>>>
>>> formatter = pf.PrettyFormatter()
>>> print(formatter(mapping))
{
    'key1': 1,
    'key2': OrderedDict({
        'key3': 3,
        'key4': 4,
    }),
    'key5': defaultdict(<class 'str'>, {
        'key6': 6,
        'a_very_long_dictionary_key7': ChainMap({
            'key10': [
                10,
                11,
                12,
                13,
            ],
            'key8': 8,
            'key9': 9,
        }),
    }),
}

[!IMPORTANT]

  • The minimum (tested) python version required to use the PyPformat package is 3.9.
  • The complete functionality of the PyPformat package (including all format configuration options) is described in the PyPformat - Usage document.
  • While the PyPformat package is already quite versatile and customizable, its development is ongoing. A detailed list of the planned features/improvements can be found in the PyPformat - TODO document.


Installation

The PyPformat package can be installed via pip:

pip install pypformat


For developers

The PyPformat - Dev notes document contains the information about project development, testing and formatting.



Licence

The PyPformat project is licenced under the MIT Licence, which can be inspected in the LICENCE file in the project's root directory.

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

pypformat-1.0.1.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

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

pypformat-1.0.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file pypformat-1.0.1.tar.gz.

File metadata

  • Download URL: pypformat-1.0.1.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for pypformat-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6b95f05c2f0bfb050b8aea9ddef46b041039ebc76a95bab4df601810b37b85c5
MD5 9dc3106f2bb94656d5f5f15871c18eba
BLAKE2b-256 f6ea5f545319262c53042be5d9a99561ebbadb1226ed48a742b79d896c90e2bc

See more details on using hashes here.

File details

Details for the file pypformat-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pypformat-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for pypformat-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 16adaa8b2f6735d51c21bf03c33a70bc8e252d2ad6e48300fc749a263686bd5b
MD5 2ac4dc6bf8d222ef67b303c7dbc53534
BLAKE2b-256 c1c08c62ac62fdb0bcd0c0627735657d3b7e83c9a493d5f64f92f631c3a2bc4b

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