add Object.__str__()

This commit is contained in:
Lance Edgar 2012-07-11 00:42:18 -05:00
parent 1a9c65ae1c
commit 03c51eb634

View file

@ -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():
"""