PrettyObject

Contents

PrettyObject#

class brainstate.util.PrettyObject[source]#

Base class for generating pretty representations of tree-like structures.

This class extends PrettyRepr to provide a mechanism for generating human-readable, pretty representations of tree-like data structures. It utilizes custom functions to represent the object and its attributes in a structured and visually appealing format.

The pretty representation is generated through the __pretty_repr__ method, which yields a sequence of pretty representation items using the general-purpose representation functions.

Examples

>>> class MyTree(PrettyObject):
...     def __init__(self, value):
...         self.value = value
>>> tree = MyTree(42)
>>> print(tree)  # Uses __pretty_repr__ for display