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.1.1.tar.gz (18.4 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.1.1-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pypformat-1.1.1.tar.gz
Algorithm Hash digest
SHA256 5cbea05720e0d543efd0faab4e8e851905281a48040c21b7d641faca539d3b3e
MD5 bfa7d556d6150bb69fe55010b48b5140
BLAKE2b-256 68b0c7e0f711871d054e9ba68db305a5c90f710bd63da232a81b70d8fc3f5601

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pypformat-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.8 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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 850170c9576727f3a62913e59bb9073eb5583d9c5afafab8c3c84f6d8ac5aabd
MD5 7ce2ae1c49637041ce9ac5e627dd52e6
BLAKE2b-256 b014915a811474990d7ff2eb581701350c7b7cb9fafbeb3c15a3120f5332d539

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