open() and EOFError
greg.ewing at canterbury.ac.nz
Tue Jul 8 00:04:19 CEST 2014
Terry Reedy wrote:
> Avoid EOFError. Much better, I think, is the somewhat customary
> s = input("Enter something, or hit <return> to exit")
> if not s: sys.exit()
> else: <process s>
I beg to differ -- on Unix, Ctrl-D *is* the customary
way to exit from something that's reading from stdin.
In any case, you need to be able to handle EOF gracefully
if the user uses it.
More information about the Python-list