Print objects with data beautifully
Project description
printo: print objects with data beautifully
A mini library for writing beautiful __repr__ for your classes.
Install it:
pip install printo
And use:
from printo import descript_data_object
print(descript_data_object('MyClassName', (1, 2, 'some text'), {'variable_name': 1, 'second_variable_name': 'kek'}))
# > MyClassName(1, 2, 'some text', variable_name=1, second_variable_name='kek')
You can prevent individual fields from being displayed. To do this, pass a dict as the filters parameter, in which the argument numbers (counting starts from 0) for positional arguments or the argument names for named arguments will be used as keys, and returning bool functions (each of them answers the question "whether to display this argument", where True means "yes" and False means "no") will be used as values:
print(descript_data_object('MyClassName', (1, 2, 'some text'), {'variable_name': 1, 'second_variable_name': 'kek'}, filters={1: lambda x: False if x == 2 else True, 'second_variable_name': lambda x: False}))
# > MyClassName(1, 'some text', variable_name=1)
You can also save a few characters by specifying a function as a filter that automatically filters None of the values:
from printo import not_none
print(descript_data_object('MyClassName', (1, None), {}, filters={1: not_none}))
# > MyClassName(1)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file printo-0.0.6.tar.gz.
File metadata
- Download URL: printo-0.0.6.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
addbc25fd1cd26b7948bc37b877d4c6b4fe10442cff3a57ab00bf893b6c17fc5
|
|
| MD5 |
1de4f14faea17badd32f23edbb964754
|
|
| BLAKE2b-256 |
3eaf1232f7c5eb677971ec2141fd7471de7f2024593b0bc53072a53c0a3c334f
|
Provenance
The following attestation bundles were made for printo-0.0.6.tar.gz:
Publisher:
release.yml on pomponchik/printo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
printo-0.0.6.tar.gz -
Subject digest:
addbc25fd1cd26b7948bc37b877d4c6b4fe10442cff3a57ab00bf893b6c17fc5 - Sigstore transparency entry: 585073564
- Sigstore integration time:
-
Permalink:
pomponchik/printo@b14cd293e5beb884a43cba54eb6db8567abbfb89 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pomponchik
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b14cd293e5beb884a43cba54eb6db8567abbfb89 -
Trigger Event:
push
-
Statement type:
File details
Details for the file printo-0.0.6-py3-none-any.whl.
File metadata
- Download URL: printo-0.0.6-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf972c2f7e80ba606f6a44e9f58b11d50e5aa0dc823034249aad9f806e7438ee
|
|
| MD5 |
38fc75f23c72c70843ba90d0f9668a6c
|
|
| BLAKE2b-256 |
953706767659d99c8138005a8ceb4c466d1efd830d2e23f1e3e039fff9a5a3e6
|
Provenance
The following attestation bundles were made for printo-0.0.6-py3-none-any.whl:
Publisher:
release.yml on pomponchik/printo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
printo-0.0.6-py3-none-any.whl -
Subject digest:
bf972c2f7e80ba606f6a44e9f58b11d50e5aa0dc823034249aad9f806e7438ee - Sigstore transparency entry: 585073582
- Sigstore integration time:
-
Permalink:
pomponchik/printo@b14cd293e5beb884a43cba54eb6db8567abbfb89 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pomponchik
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b14cd293e5beb884a43cba54eb6db8567abbfb89 -
Trigger Event:
push
-
Statement type: