Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Gregory Ewing Newsgroups: comp.lang.python Subject: Re: open() and EOFError Date: Tue, 08 Jul 2014 10:04:19 +1200 Lines: 15 Message-ID: References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net cngmYtEqDXJ2SSqqvP1ewg4n6HhN7BUcOm34D4XOmgsp4coFGY Cancel-Lock: sha1:9ROL9rCvy059D7DtdNILHZnELmM= User-Agent: Mozilla Thunderbird 1.0.5 (Macintosh/20050711) X-Accept-Language: en-us, en In-Reply-To: Xref: csiph.com comp.lang.python:74138 Terry Reedy wrote: > Avoid EOFError. Much better, I think, is the somewhat customary > > s = input("Enter something, or hit to exit") > if not s: sys.exit() > else: 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. -- Greg