Skip to content

Reference

ellipsize

Pretty reducing huge Python objects to visualise them nicely.

Modules

ellipsize.ellipsize

Visualize huge Python objects as nicely reduced strings.

Classes
ellipsize.ellipsize.Dots

Bases: dict

Show dots inside Python objects repr.

Functions
ellipsize.ellipsize.ellipsize
ellipsize(obj: Any, max_items_to_show: int = 10, max_item_length: int = 1024) -> Any

Reduce huge list/dict to show on screen.

In lists (including dict items) show only 1st max_list_items_to_show and add ".." if there is more. Limit max dict/list length at max_item_length.

Args: obj: Python object to ellipsize max_items_to_show: if List or Dict in obj (including nested) has more items, then show ".." instead of the rest items max_item_length: if List's or Dict's item are not another List/Dict and his string representation longer than show ".." instead of the rest of it

ellipsize.ellipsize.ellipsize_dict
ellipsize_dict(obj: dict[Any, Any], max_items_to_show: int, max_item_length: int) -> dict[Any, Any]

Ellipsize dict.

ellipsize.ellipsize.ellipsize_list
ellipsize_list(obj: list[Any], max_items_to_show: int, max_item_length: int) -> list[Any]

Ellipsize list.

ellipsize.ellipsize.format_ellipsized
format_ellipsized(obj: Any, max_items_to_show: int = 10, max_item_length: int = 1024) -> str

Pformat ellipsized obj.

Use pprint.pformat to convert ellipsize result into string

Args: obj: Python object to ellipsize max_items_to_show: if List or Dict in obj (including nested) has more items, then show ".." instead of the rest items max_item_length: if List's or Dict's item are not another List/Dict and his string representation longer than show ".." instead of the rest of it

ellipsize.ellipsize.print_ellipsized
print_ellipsized(*objs: Any, max_items_to_show: int = 10, max_item_length: int = 1024, **kwargs: Any) -> None

Print ellipsized obj with pprint.

Can print many objects, like general print. Pass args to print like end.

Args: objs: Python objects to ellipsize max_items_to_show: if List or Dict in objs (including nested) has more items, then show ".." instead of the rest items max_item_length: if List's or Dict's item are not another List/Dict and his string representation longer than show ".." instead of the rest of it