Added __repr__() method to Connection()
[diaspy.git] / diaspy / connection.py
index 9ce40570e69f628b7fb3a8fc395ed76d40d79592..786158b8ffca9ef2464678254418cbc4f8af36b7 100644 (file)
@@ -43,6 +43,14 @@ class Connection():
         except Exception as e:
             raise LoginError('cannot create login data (caused by: {0}'.format(e))
 
+    def __repr__(self):
+        """Returns token string.
+        It will be easier to change backend if programs will just use:
+            repr(connection)
+        instead of calling a specified method.
+        """
+        return self.get_token()
+
     def get(self, string, headers={}, params={}):
         """This method gets data from session.
         Performs additional checks if needed.