From: W. Trevor King Date: Tue, 5 Feb 2013 15:16:26 +0000 (-0500) Subject: Catch EOFError (control-d) in CommandLineInterface input() call X-Git-Tag: v0.1~67 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=323414c4018e13bd910f2433d649a33a5b054bde;p=quizzer.git Catch EOFError (control-d) in CommandLineInterface input() call --- 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()