work around ipython breaking input()

This commit is contained in:
2026-03-11 17:08:41 +01:00
parent ce2fe430a0
commit 84ab2b831f
+13 -4
View File
@@ -1,8 +1,17 @@
import sys
try:
read_input = input # py3
except NameError:
read_input = raw_input # py2
# ipython changes input() such that KeyboardInterrupt is ignored
# this reimplements working ctrl-c and ctrl-d
def read_input(prompt=""):
sys.stdout.write(prompt)
sys.stdout.flush()
line = sys.stdin.readline()
if line == "":
raise EOFError
return line.rstrip("\n")