Better __repr__() for data model
This greatly enhances debugability of data model objects as repr() and str() of objects contain now all attributes. TODO: Check for secret attributes Change-Id: I2babd600516cfe98673627c68e97cb581ee54834
This commit is contained in:
parent
53200266b3
commit
cc7797ed33
|
@ -76,6 +76,11 @@ class BaseDataModel():
|
|||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
def __repr__(self):
|
||||
attrs = " ".join(
|
||||
"{}={!r}".format(k, v) for k, v in self.__dict__.items())
|
||||
return f"{self.__class__.__name__}({attrs})"
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, dict):
|
||||
return cls(**dict)
|
||||
|
|
Loading…
Reference in New Issue