]> git.notmuchmail.org Git - notmuch/blobdiff - bindings/python/notmuch/message.py
use __unicode__ for string representation
[notmuch] / bindings / python / notmuch / message.py
index 6ee5ec95e0bae524ba54f453f87335dad64da5eb..a9ded8018489c082ae86888b7b3797f2f5d940b6 100644 (file)
@@ -796,12 +796,14 @@ class Message(object):
         return self.__str__()
 
     def __str__(self):
-        """A message() is represented by a 1-line summary"""
-        msg = {}
-        msg['from'] = self.get_header('from')
-        msg['tags'] = self.get_tags()
-        msg['date'] = date.fromtimestamp(self.get_date())
-        return "%(from)s (%(date)s) (%(tags)s)" % (msg)
+        return unicode(self).encode('utf-8')
+
+    def __unicode__(self):
+        format = "%(from)s (%(date)s) (%(tags)s)"
+        return format % (self.get_header('from'),
+                         self.get_tags(),
+                         date.fromtimestamp(self.get_date()),
+                        )
 
     def get_message_parts(self):
         """Output like notmuch show"""