From: W. Trevor King Date: Tue, 5 Feb 2013 15:27:16 +0000 (-0500) Subject: question: Add Question.__str__() and __repr__() X-Git-Tag: v0.1~66 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2fa4bc84af9ac6d323462d97cd85d571b48148b5;p=quizzer.git question: Add Question.__str__() and __repr__() For easily viewing questions in lists. --- diff --git a/quizzer/question.py b/quizzer/question.py index 065b17e..e423adf 100644 --- a/quizzer/question.py +++ b/quizzer/question.py @@ -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,