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.0.tar.gz (16.5 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.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pypformat-1.0.0.tar.gz
  • Upload date:
  • Size: 16.5 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.0.tar.gz
Algorithm Hash digest
SHA256 1bb5678b8cc39f8b3e9988fc5ad34b6eb3897747a206985b538f18f56c076585
MD5 e8f0c0617e633f502867cba085e9b3f8
BLAKE2b-256 24de8e6f1db1ba4f4f117b6f6910b20b4f040703ce40d8ace3ed59e560d79c1d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pypformat-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6932c32ecc8f74530561eadd91f7296a0012a9ecdc0f266a1bd3898dd672619b
MD5 75142c3feb6eccb0b70dcc76ad6b20a2
BLAKE2b-256 67483ffc6d7a661120430043ebf4bdc06087f0e7a8e41a5d5dff9d3ede52f119

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