Skip to content

treex.ToString

Mixin that adds a .to_string() method to the class.

to_string(self, *, private_fields=False, static_fields=True, color=False)

to_string is a wrapper over treeo.to_string that passes self as the first argument.

Parameters:

Name Type Description Default
private_fields bool

If True, private fields are included.

False
static_fields bool

If True, static fields are included.

True
color bool

If True, color is included.

False

Returns:

Type Description
str

A string representation of the object.

Source code in treeo/mixins.py
def to_string(
    self: A,
    *,
    private_fields: bool = False,
    static_fields: bool = True,
    color: bool = False,
) -> str:
    """
    `to_string` is a wrapper over `treeo.to_string` that passes `self` as the first argument.

    Arguments:
        private_fields: If `True`, private fields are included.
        static_fields: If `True`, static fields are included.
        color: If `True`, color is included.

    Returns:
        A string representation of the object.
    """
    return api.to_string(
        self,
        private_fields=private_fields,
        static_fields=static_fields,
        color=color,
    )