StringRepresentable

class zixy.container.base.StringRepresentable[source]

Bases: ABC

Abstract base class for classes that can be represented as, and constructed from, strings.

abstractmethod __repr__() str[source]

Return a string representation of self.

abstractmethod classmethod from_str(source: str, *args: Any, **kwargs: Any) Self[source]

Create an instance of cls from a string.

Parameters:
  • source – String to parse.

  • *args – Positional arguments to forward to a subsequent constructor.

  • **kwargs – Keyword arguments to forward to a subsequent constructor.

Returns:

An instance of cls parsed from source.

classmethod parse(source: str) Self[source]

Parse a string into an instance of cls.

Deprecated:

use from_str() instead.

Parameters:

source – String to parse.

Returns:

An instance of cls parsed from source.

to_str() str[source]

Return the canonical string representation of self.