question: Add Question.__str__() and __repr__()
authorW. Trevor King <wking@tremily.us>
Tue, 5 Feb 2013 15:27:16 +0000 (10:27 -0500)
committerW. Trevor King <wking@tremily.us>
Tue, 5 Feb 2013 15:27:16 +0000 (10:27 -0500)
For easily viewing questions in lists.

quizzer/question.py

index 065b17e86dbb80ad0438c0fe2172e6da3fa82b88..e423adf0da629d40b9e8feaef49931f54c5c1808 100644 (file)
@@ -11,6 +11,13 @@ class Question (object):
             dependencies = []
         self.dependencies = dependencies
 
+    def __str__(self):
+        return '<{} id:{!r}>'.format(type(self).__name__, self.id)
+
+    def __repr__(self):
+        return '<{} id:{!r} at {:#x}>'.format(
+            type(self).__name__, self.id, id(self))
+
     def __getstate__(self):
         return {
             'id': self.id,