mlrl.util.format module

Author: Michael Rapp (michael.rapp.ml@gmail.com)

Provides utility functions for creating textual representations.

mlrl.util.format.format_enum_values(enum: type[Enum]) str

Creates and returns a textual representation of an enum’s values.

Parameters:

enum – The enum to be formatted

Returns:

The textual representation that has been created

mlrl.util.format.format_iterable(objects: Iterable[Any], separator: str = ', ', delimiter: str = '') str

Creates and returns a textual representation of objects in an iterable.

Parameters:
  • objects – The iterable of objects to be formatted

  • separator – The string that should be used as a separator

  • delimiter – The string that should be added at the beginning and end of each object

Returns:

The textual representation that has been created

mlrl.util.format.format_list(objects: list[Any], separator: str = ',  ', delimiter: str = '', last_separator: str | None = None) str

Creates and returns a textual representation of objects in a list.

Parameters:
  • objects – The list of objects to be formatted

  • separator – The string that should be used as a separator

  • delimiter – The string that should be added at the beginning and end of each object

  • last_separator – The string that should be used as the last separator or None, if separator should be used

Returns:

The textual representation that has been created

mlrl.util.format.format_set(objects: Iterable[Any]) str

Creates and returns a textual representation of the objects in a set.

Parameters:

objects – The iterable of objects to be formatted

Returns:

The textual representation that has been created

mlrl.util.format.format_value(value: Any) str

Creates and returns a textual representation of a given value.

Parameters:

value – The value to be formatted

Returns:

The textual representation that has been created