Catch EOFError (control-d) in CommandLineInterface input() call
authorW. Trevor King <wking@tremily.us>
Tue, 5 Feb 2013 15:16:26 +0000 (10:16 -0500)
committerW. Trevor King <wking@tremily.us>
Tue, 5 Feb 2013 15:16:26 +0000 (10:16 -0500)
quizzer/ui/cli.py

index 52b6a8328be9b9d4a6af7337445df620108d1ff6..a82843fd71252daae3786fcdde9237b6aee7d11c 100644 (file)
@@ -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()