Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!panix!not-for-mail From: Grant Edwards Newsgroups: comp.lang.python Subject: Re: open() and EOFError Date: Tue, 8 Jul 2014 14:19:34 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 23 Message-ID: References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> NNTP-Posting-Host: dsl.comtrol.com X-Trace: reader1.panix.com 1404829174 20032 64.122.56.22 (8 Jul 2014 14:19:34 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Tue, 8 Jul 2014 14:19:34 +0000 (UTC) User-Agent: slrn/1.0.1 (Linux) Xref: csiph.com comp.lang.python:74166 On 2014-07-07, Gregory Ewing wrote: > 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. Indeed. Ctrl-D is _the_ canonical way to tell a program that's reading stdin that your're done. I've never run across "hit to exit". > In any case, you need to be able to handle EOF gracefully if the user > uses it. -- Grant Edwards grant.b.edwards Yow! Nipples, dimples, at knuckles, NICKLES, gmail.com wrinkles, pimples!!