class/str
This commit is contained in:
parent
487d7cb9b2
commit
8227524a7c
1 changed files with 15 additions and 2 deletions
|
@ -2,14 +2,16 @@
|
|||
|
||||
__version__ = "0.0.1"
|
||||
|
||||
from os import linesep
|
||||
|
||||
|
||||
class Class:
|
||||
"""Root class."""
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""Represent object variables.
|
||||
"""Return machine-readable state.
|
||||
|
||||
:return: representation
|
||||
:return: state
|
||||
:rtype: str
|
||||
"""
|
||||
name = self.__class__.__name__
|
||||
|
@ -18,3 +20,14 @@ class Class:
|
|||
]
|
||||
arguments = ", ".join(attributes)
|
||||
return f"{name}({arguments})"
|
||||
|
||||
def __str__(self) -> str:
|
||||
"""Return human-readable state.
|
||||
|
||||
:return: state
|
||||
:rtype: str
|
||||
"""
|
||||
attributes = [
|
||||
f"{k} = {v}" for k, v in vars(self).items() if not k.startswith("_")
|
||||
]
|
||||
return linesep.join(attributes)
|
||||
|
|
Loading…
Reference in a new issue