From 323414c4018e13bd910f2433d649a33a5b054bde Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 5 Feb 2013 10:16:26 -0500 Subject: [PATCH] Catch EOFError (control-d) in CommandLineInterface input() call --- quizzer/ui/cli.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/quizzer/ui/cli.py b/quizzer/ui/cli.py index 52b6a83..a82843f 100644 --- a/quizzer/ui/cli.py +++ b/quizzer/ui/cli.py @@ -9,7 +9,10 @@ class CommandLineInterface (UserInterface): break print(question.prompt) while True: - answer = input('? ') + try: + answer = input('? ') + except EOFError: + answer = 'quit' a = answer.strip().lower() if a in ['q', 'quit']: print() -- 2.26.2