Skip to main content
logo.png

Python Project prettyclass

GitHubWorkflow Read the Docs GitHub GitHub release PyPI Version PyPI - Python Version PyPI Downloads

Introduction

To import the project simply type

>>> import prettyclass

after installation.

>>> from prettyclass import prettyclass

>>> @prettyclass()
... class ABC:
...     def __init__(self, a, *b, c, d=1, e, **f):
...         '''creates ABC instance'''

The decorator adds automaticly all argument fields as attributes.

>>> abc = ABC(1, 2, [3, 4], c=5, d=6, e=7, g='A', h='B')
>>> abc.__dict__
{'a': 1, 'b': (2, [3, 4]), 'c': 5, 'd': 6, 'e': 7, 'f': {'g': 'A', 'h': 'B'}}

>>> abc.a, abc.b, abc.c, abc.d, abc.e, abc.f
(1, (2, [3, 4]), 5, 6, 7, {'g': 'A', 'h': 'B'})

and returns a pretty nice representation of an instance

>>> abc
ABC(1, 2, [3, 4], c=5, d=6, e=7, g='A', h='B')

Note the difference between ‘str’ and ‘repr’

>>> str(abc)
'ABC(1, 2, [3, 4], c=5, d=6, e=7, g=A, h=B)'

>>> repr(abc)
"ABC(1, 2, [3, 4], c=5, d=6, e=7, g='A', h='B')"

Copy works by default, too.

>>> from copy import copy
>>> copy(abc)
ABC(1, 2, [3, 4], c=5, d=6, e=7, g='A', h='B')

Note, the string representation commits entries which coincide with defaults

>>> ABC(1, 2, [3, 4], c=5, d=1, e=7, g='A', h='B')
ABC(1, 2, [3, 4], c=5, e=7, g='A', h='B')

Documentation

More documentation available at https://prettyclass.readthedocs.io

Install

The latest stable version can always be installed or updated via pip:

$ pip install prettyclass

License

Code and documentation are available according to the license (see LICENSE file in repository).

Metadata

Release files for prettyclass 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prettyclass 0.1.1
File Size Uploaded Provenance Actions
prettyclass-0.1.1.zip 15.0 kB Without provenance Details for prettyclass-0.1.1.zip

Release files / prettyclass-0.1.1.zip

Download URL prettyclass-0.1.1.zip
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9498d29945e91a77043bda56185991815b1902fa8cab7cea5b0eacb8f5d5bc5e
BLAKE2b-256 checksum
How to use checksums
4ffba6325d0374dbf5b2ce2a87bfe7fb03bf7f316de40e8716d6eb0ad7a1e59f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.11

Security for prettyclass 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page