Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2a.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'interpreter': 0.05; 'convention.': 0.07; 'detect': 0.07; 'filenames': 0.09; 'intriguing': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; "(it's": 0.16; '>try:': 0.16; 'ebcdic': 0.16; 'eof': 0.16; 'expecting': 0.16; 'message-id:@4ax.com': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'command': 0.22; 'this?': 0.23; '(by': 0.24; 'url:home': 0.24; 'header:X-Complaints-To:1': 0.27; 'character': 0.29; "i'm": 0.30; 'code': 0.31; 'usually': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'file': 0.32; "i'd": 0.34; 'basic': 0.35; 'display': 0.35; 'but': 0.35; 'data,': 0.36; 'entry': 0.36; 'charset:us-ascii': 0.36; 'expected': 0.38; 'to:addr:python-list': 0.38; 'expect': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'blank': 0.60; 'entire': 0.61; 'first': 0.61; 'making': 0.63; 'name': 0.63; 'jul': 0.74; 'xerox': 0.84; 'received:108': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: open() and EOFError Date: Mon, 07 Jul 2014 18:54:13 -0400 Organization: IISS Elusive Unicorn 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=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-108-73-117-74.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1404773667 news.xs4all.nl 2847 [2001:888:2000:d::a6]:50555 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:74140 On 07 Jul 2014 08:00:14 GMT, Steven D'Aprano declaimed the following: >How do people feel about code like this? > >try: > name = input("Enter file name, or Ctrl-D to exit") Personally -- I usually use "... to exit" with the implication that a null entry means exit... if name == "" then sys.exit() Of course, if I'm prompting in the first place, I'm not expecting to be reading a (redirected?) file for data, or I'd expect the file to follow the expected (by me) blank line convention. Prompting for an EOF is so system dependent... (It's been 35 years, but I think Xerox CP/V used for EOF; it also allowed the character in file names, making for intriguing entry of filenames on the command line [the BASIC interpreter DIR command would detect the non-visible character and display the entire file name in hex... EBCDIC hex]) -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/