PyPformat
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, Counter, OrderedDict, UserDict, 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}
... ),
... "key11": Counter("Hello"),
... },
... ),
... "key12": UserDict({0: "a", 1: "b", 2: "c"}),
... }
>>>
>>> pprint(mapping)
{'key1': 1,
'key12': {0: 'a', 1: 'b', 2: 'c'},
'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}),
'key11': Counter({'l': 2, 'H': 1, 'e': 1, 'o': 1}),
'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,
}),
'key11': Counter({
'H': 1,
'e': 1,
'l': 2,
'o': 1,
}),
}),
'key12': {
0: 'a',
1: 'b',
2: 'c',
},
}
[!IMPORTANT]
- The minimum (tested) python version required to use the
PyPformatpackage is 3.9.- The complete functionality of the
PyPformatpackage (including all format configuration options) is described in PyPformat - Usage and PyPformat - Utility documents.- While the
PyPformatpackage 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 (please note that this list is not fixed and may be expanded).
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.
Release files for pypformat 1.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pypformat-1.2.4.tar.gz | 19.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pypformat-1.2.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.0 kB
Release files / pypformat-1.2.4.tar.gz
| Download URL | pypformat-1.2.4.tar.gz |
|---|---|
| Size | 19.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
80226d4accb55e94504d6619536513f02c5dbcda4e89b264e013fa0d507a3a92
|
|
BLAKE2b-256 checksum How to use checksums |
d3eb1d61305968294b6609dc21087b645b818a1ba99e5821c50c26b251f02037
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.1
|
Release files / pypformat-1.2.4-py3-none-any.whl
| Download URL | pypformat-1.2.4-py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3d72f0f5de7b82d2ed4eff06f6d8e686e64685074f967c1d0be0439d6b3444e9
|
|
BLAKE2b-256 checksum How to use checksums |
4a2d9477b659856fac07370a44e2e267602cbcc4a412265b198a89a914e5134e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.1
|