Spaces:
Runtime error
Runtime error
File size: 370 Bytes
8fd2f2f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
class AsDictMixin:
def to_dict(self):
keys = [entry for entry in dir(self) if not callable(getattr(
self, entry)) and not entry.startswith("__")]
result_dict = {}
for key in keys:
result_dict[key] = getattr(self, key)
return result_dict
def __str__(self) -> str:
return self.to_dict().__str__() |