Skip to main content

Print objects with data beautifully

Project description

printo: print objects with data beautifully

Downloads Downloads Coverage Status Lines of code Hits-of-Code Test-Package Python versions PyPI version Checked with mypy Ruff

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

printo-0.0.6.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

printo-0.0.6-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

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

Hashes for printo-0.0.6.tar.gz
Algorithm Hash digest
SHA256 addbc25fd1cd26b7948bc37b877d4c6b4fe10442cff3a57ab00bf893b6c17fc5
MD5 1de4f14faea17badd32f23edbb964754
BLAKE2b-256 3eaf1232f7c5eb677971ec2141fd7471de7f2024593b0bc53072a53c0a3c334f

See more details on using hashes here.

Provenance

The following attestation bundles were made for printo-0.0.6.tar.gz:

Publisher: release.yml on pomponchik/printo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for printo-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 bf972c2f7e80ba606f6a44e9f58b11d50e5aa0dc823034249aad9f806e7438ee
MD5 38fc75f23c72c70843ba90d0f9668a6c
BLAKE2b-256 953706767659d99c8138005a8ceb4c466d1efd830d2e23f1e3e039fff9a5a3e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for printo-0.0.6-py3-none-any.whl:

Publisher: release.yml on pomponchik/printo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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