1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Added a string representation (__str__) for JsonDeserializable

This commit is contained in:
pieter 2015-09-01 21:55:02 +02:00
parent 3c8faa155f
commit cf61577e3e

View File

@ -68,6 +68,16 @@ class JsonDeserializable:
else: else:
raise ValueError("json_type should be a json dict or string.") raise ValueError("json_type should be a json dict or string.")
def __str__(self):
d = {}
for x, y in self.__dict__.iteritems():
if hasattr(y, '__dict__'):
d[x] = y.__dict__
else:
d[x] = y
return unicode(d)
class User(JsonDeserializable): class User(JsonDeserializable):
@classmethod @classmethod