Skip to main content

Library for beautiful object formatting

Project description

Beautiful-repr

Helps structure the formatting of objects in Python.

Installation

pip install beautiful-repr

Why Beautiful-repr ?

  • Beautiful repr out of the box
  • Great expansion possibilities
  • Very small and simple
  • No external dependencies

Example

from beautiful_repr import *


class ShoppingCart(StylizedMixin):
    _repr_fields = (
        Field("token", value_transformer=lambda value: value[1:]),
        Field(
            "products",
            value_getter=parse_length,
            formatter=TemplateFormatter("{value} products")
        ),
    )

    def __init__(self, token: str, products: tuple[str, ] = tuple()):
        self.token = token
        self.products = tuple(products)


print(ShoppingCart("s12345", ("Potato", "iPhone", "New Vegas")))

output: ShoppingCart(token=12345, 3 products)

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

beautiful_repr-1.1.1.tar.gz (3.4 kB view details)

Uploaded Source

File details

Details for the file beautiful_repr-1.1.1.tar.gz.

File metadata

  • Download URL: beautiful_repr-1.1.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for beautiful_repr-1.1.1.tar.gz
Algorithm Hash digest
SHA256 15a6c8eb1ed52710d32c29dd04a3785df5659b719a7ac640499021c6df3389d5
MD5 b976d9530e7f0046ebb971ac15a3947f
BLAKE2b-256 ec6c027a7983213bc09505cbfde258916aac6f8bb05586feeab27e86ca0bd84b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page