From 2fa4bc84af9ac6d323462d97cd85d571b48148b5 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 5 Feb 2013 10:27:16 -0500 Subject: [PATCH] question: Add Question.__str__() and __repr__() For easily viewing questions in lists. --- quizzer/question.py | 7 +++++++ 1 file changed, 7 insertions(+) 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, -- 2.26.2