Added __str__() and __repr__() to people.User()
authorMarek Marecki <triviuss@gmail.com>
Fri, 5 Jul 2013 23:12:45 +0000 (01:12 +0200)
committerMarek Marecki <triviuss@gmail.com>
Fri, 5 Jul 2013 23:12:45 +0000 (01:12 +0200)
diaspy/people.py

index 8107ab2194efdd2a94919c055cc26bed87d490bd..25677fb10ea27f775a32676f155b3ac358bbf0a5 100644 (file)
@@ -31,13 +31,19 @@ class User():
         self.data = {
             'guid': guid,
             'handle': handle,
-            'id': id
+            'id': id,
         }
         self._do_fetch(fetch)
 
     def __getitem__(self, key):
         return self.data[key]
 
+    def __str__(self):
+        return self['guid']
+
+    def __repr__(self):
+        return '{0} ({1})'.format(self['diaspora_name'], self['guid'])
+
     def _do_fetch(self, fetch):
         if fetch == 'posts':
             if self['handle'] and self['guid']: self.fetchguid()