Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'suppose': 0.07; 'think,': 0.07; 'below).': 0.09; 'correct,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'jan': 0.12; 'windows': 0.15; 'eof': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'roy': 0.16; 'tty': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'driver': 0.24; 'library,': 0.24; 'stick': 0.24; '(or': 0.24; "i've": 0.25; '(see': 0.26; 'mention': 0.26; 'header:X-Complaints- To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'character': 0.29; 'mode': 0.30; "i'm": 0.30; 'embedding': 0.31; 'probably': 0.32; 'running': 0.33; 'raw': 0.33; 'maybe': 0.34; 'could': 0.34; 'problem': 0.35; 'something': 0.35; 'doubt': 0.36; 'useful': 0.36; 'possible': 0.36; 'being': 0.38; 'to:addr:python- list': 0.38; 'received:71': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'even': 0.60; 'most': 0.60; 'telling': 0.64; 'more': 0.64; 'different': 0.65; 'smith': 0.68; 'topic,': 0.81; 'fan,': 0.84; 'received:fios.verizon.net': 0.84; 'technically': 0.84; 'hand,': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: open() and EOFError Date: Mon, 07 Jul 2014 14:49:56 -0400 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=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-71-175-90-87.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1404759029 news.xs4all.nl 2917 [2001:888:2000:d::a6]:59533 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:74133 On 7/7/2014 8:39 AM, Roy Smith wrote: > On a different topic, I've always disliked embedding instructions to > "type Ctrl-D". The problem is, how to generate an EOF (or interrupt, or > whatever) is configurable in the tty driver (see below). In theory, the > user could have remapped EOF to be something else. Maybe they're a > die-hard Windows fan, and insist on being able to type Ctrl-Z for EOF. > Not to mention that things like readline are probably running the > terminal in raw mode and remapping everything all over again. > > On the other hand, telling the user to "generate EOF", while technically > more correct, is not very useful for most people. I suppose you could > interrogate the tty driver to find out what the current EOF character > is, and stick that in your prompt. I don't even know if that's possible > with the standard Python library, and I doubt it would be very portable. > I'm not sure what the best solution is here. Avoid EOFError. Much better, I think, is the somewhat customary s = input("Enter something, or hit to exit") if not s: sys.exit() else: -- Terry Jan Reedy