From 03c51eb6343917cdf5051c7e228f13c17e49cdb9 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 11 Jul 2012 00:42:18 -0500 Subject: [PATCH] add Object.__str__() --- edbob/core.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/edbob/core.py b/edbob/core.py index 04a00ea..1d9f44e 100644 --- a/edbob/core.py +++ b/edbob/core.py @@ -57,6 +57,16 @@ class Object(object): if hasattr(self, key): return getattr(self, key) + def __str__(self): + """ + Leverage :meth:`__unicode__()` method if it exists; otherwise fall back + to ``repr(self)``. + """ + + if hasattr(self, '__unicode__'): + return str(unicode(self)) + return repr(self) + def basic_logging(): """