Frazer McLean

Simply, represent exists to simplify the creation of useful __repr__ functions for your Python classes.

You can replace this:

class Car:
    def __init__(self, color, mass, type_):
        self.color = color
        self.mass = mass
        self.type_ = type_

    def __repr__(self):
        return (
            f'{self.__class__.__name__}('
            f'color={self.color!r}, '
            f'mass={self.mass}, '
            f'type_={self.type_!r})'
        )

with this:

from represent import ReprHelperMixin

class Car(ReprHelperMixin):
    def __init__(self, color, mass, type_):
        self.color = color
        self.mass = mass
        self.type_ = type_

    def _repr_helper_(self, r):
        r.keyword_from_attr('color')
        r.keyword_from_attr('mass')
        r.keyword_from_attr('type_')

There are more methods that can be called on the r object, which you can check out in the documentation.