[go: up one dir, main page]

Skip to content

emptybutton/Beautiful-repr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

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)

About

Library for beautiful object formatting

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages