From cf61577e3e13f2246dee9214d07e3b913db72f1c Mon Sep 17 00:00:00 2001 From: pieter Date: Tue, 1 Sep 2015 21:55:02 +0200 Subject: [PATCH] Added a string representation (__str__) for JsonDeserializable --- telebot/types.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/telebot/types.py b/telebot/types.py index 74965bb..4c57034 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -68,6 +68,16 @@ class JsonDeserializable: else: 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): @classmethod