Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed3a.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.022 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'else:': 0.03; 'think,': 0.07; 'string': 0.09; 'cc:addr:python-list': 0.11; 'exiting': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'reedy': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'mon,': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; 'that.': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'data,': 0.36; 'application': 0.37; 'two': 0.37; 'sometimes': 0.38; 'pm,': 0.38; 'signal': 0.60; 'different': 0.65; 'jul': 0.74; 'special': 0.74; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=IzpdPNaLYItwCl5gxA+g1VjmwNDmxKGx/W5AfleORqU=; b=MegJNnb5+HUgSroxKgFrniD/y5nBhLNFjbJ4bn6R3eEPXxvoDwSGdXJxDgaAe+O5zJ 5/s98jFbVBrlAc55paJuwChB+LOjIOtWyL0ZRY35OqexOXicVmLl5X0LKyOasZkDUVHx v5C0/+ik4ftEaggkzCHbsDR5J5gl+OxRZlWo620vn9d9ubd72Ash84wmHWLCjnv6kuxF fQ7Jq+ZperU7AIreNur/WrIy8MXaXwt1HnAmHvI9/RMQwj7VdenmNRwUl3HGkHfi5O/n lMyY9LXhQOlRYAVv20XeOYVJrTyVXWGW2aJjAJdV9Qju0nCo9ToLg5cMnv8sFH8CVsvz P2WA== MIME-Version: 1.0 X-Received: by 10.221.20.199 with SMTP id qp7mr32897609vcb.24.1404815360951; Tue, 08 Jul 2014 03:29:20 -0700 (PDT) In-Reply-To: <53bbb3c6$0$2926$c3e8da3$76491128@news.astraweb.com> References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <53bbb3c6$0$2926$c3e8da3$76491128@news.astraweb.com> Date: Tue, 8 Jul 2014 20:29:20 +1000 Subject: Re: open() and EOFError From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1404815369 news.xs4all.nl 2939 [2001:888:2000:d::a6]:53869 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:74161 On Tue, Jul 8, 2014 at 7:03 PM, Steven D'Aprano wrote: > On Mon, 07 Jul 2014 14:49:56 -0400, 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: > > Under many circumstances, I would do exactly that. But sometimes an empty > string is valid data, not a signal for special processing (whether > exiting the application, or something else). Or you want to have two different signals: empty string means "use the default", and something else means "exit the application now please". Very common. ChrisA