Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #74128

Re: open() and EOFError

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.018
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'sure,': 0.09; 'yeah,': 0.09; 'cc:addr:python-list': 0.11; "wouldn't": 0.14; 'blocks': 0.16; 'combined.': 0.16; 'distinct': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'normal,': 0.16; 'readability': 0.16; 'wrote:': 0.18; 'normally': 0.19; 'possible,': 0.19; 'cc:addr:python.org': 0.22; 'case.': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; "doesn't": 0.30; 'errors': 0.30; 'message-id:@mail.gmail.com': 0.30; 'catching': 0.31; 'handled': 0.32; 'sources': 0.33; 'except': 0.35; 'problem.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'possible': 0.36; 'two': 0.37; 'expect': 0.39; 'either': 0.39; 'easy': 0.60; 'ian': 0.60; 'break': 0.61; 'more': 0.64; 'lose': 0.68; 'jul': 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=umSsmXG8yAOZ2lAnPVNr05cNbjMWw8yEVc4gg5LgAwQ=; b=vwK8prkEWubyAR6mzaCYnAXUWi9caLagKff/GxgOlyKednEZeYANhVr5h21UYEX0xo cAXJL+MQ0ApPmZ6Fc65wyXbxNVaURYXYKH3iiNEUWI2X4yu42nrYkIfJgLej6+IWcNQ+ dNQ6taA6DunvyBcGrqOaAP/eUOKKgbfnlJtm3TYqoJI5Y8b4SSLAJ4kheTEp5x1WgC+G /y13Es1pUOJHBNQJWZyy/HPw9UNnK5Z2PVyC6ih1VMM2n1SE2t5KQQ4g5FY7wBTz6EBA q7lxGXBhVyae+ZUmDcDTOML8hdt3ZDH201YCAKuymH9DY0IqiXCVOU3xOON5fbrOELSq zrLw==
MIME-Version 1.0
X-Received by 10.58.216.4 with SMTP id om4mr1510577vec.66.1404754164256; Mon, 07 Jul 2014 10:29:24 -0700 (PDT)
In-Reply-To <CALwzidmMTdUgNxANTJnsZx72ja2hf_Jw8WqH3TttYnOWcnrxzA@mail.gmail.com>
References <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <c1uo2eF60gfU1@mid.individual.net> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <CAPTjJmos00xjJVMZFKY1F9Z8L+ByusHD-ciuats5FYbwQ6RF+g@mail.gmail.com> <CALwzidmMTdUgNxANTJnsZx72ja2hf_Jw8WqH3TttYnOWcnrxzA@mail.gmail.com>
Date Tue, 8 Jul 2014 03:29:24 +1000
Subject Re: open() and EOFError
From Chris Angelico <rosuav@gmail.com>
Cc Python <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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.11604.1404754167.18130.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1404754167 news.xs4all.nl 2929 [2001:888:2000:d::a6]:55159
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:74128

Show key headers only | View raw


On Tue, Jul 8, 2014 at 3:25 AM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> On Mon, Jul 7, 2014 at 2:09 AM, Chris Angelico <rosuav@gmail.com> wrote:
>> But if the code's more complicated and it's not so easy to split, then
>> sure, doesn't seem a problem. It's like spam[foo//bar] and then
>> catching either IndexError or ZeroDivisionError - there's no big
>> confusion from having two distinct sources of two distinct errors
>> handled by two distinct except blocks.
>
> It's good practice to keep your try blocks as narrow as possible in
> any case.  One wouldn't normally expect them, but a custom __getitem__
> *could* cause a ZeroDivisionError, and a custom __floordiv__ *could*
> cause an IndexError.

Yeah, in theory. But it's not normal, and if you always break
everything out to keep exception-catching scope as narrow as possible,
you begin to lose readability in other ways. So I wouldn't object to
seeing those two combined.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

open() and EOFError Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-07-07 03:20 +0000
  Re: open() and EOFError Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-07-07 17:04 +1200
    Re: open() and EOFError Steven D'Aprano <steve@pearwood.info> - 2014-07-07 08:00 +0000
      Re: open() and EOFError Chris Angelico <rosuav@gmail.com> - 2014-07-07 18:09 +1000
      Re: open() and EOFError Dave Angel <davea@davea.name> - 2014-07-07 08:14 -0400
      Re: open() and EOFError Chris Angelico <rosuav@gmail.com> - 2014-07-07 22:19 +1000
        Re: open() and EOFError Roy Smith <roy@panix.com> - 2014-07-07 08:46 -0400
          Re: open() and EOFError Chris Angelico <rosuav@gmail.com> - 2014-07-07 22:58 +1000
            Re: open() and EOFError Roy Smith <roy@panix.com> - 2014-07-07 20:26 -0400
          Re: open() and EOFError Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-07-08 09:50 +1200
        Re: open() and EOFError Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-07-07 15:45 +0000
          Re: open() and EOFError Chris Angelico <rosuav@gmail.com> - 2014-07-08 01:53 +1000
          Re: open() and EOFError Marko Rauhamaa <marko@pacujo.net> - 2014-07-07 19:08 +0300
            Re: open() and EOFError Marko Rauhamaa <marko@pacujo.net> - 2014-07-07 19:12 +0300
      Re: open() and EOFError Roy Smith <roy@panix.com> - 2014-07-07 08:39 -0400
        Re: open() and EOFError Chris Angelico <rosuav@gmail.com> - 2014-07-07 22:55 +1000
          Re: open() and EOFError Roy Smith <roy@panix.com> - 2014-07-07 20:28 -0400
        Re: open() and EOFError Terry Reedy <tjreedy@udel.edu> - 2014-07-07 14:49 -0400
          Re: open() and EOFError Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-07-08 10:04 +1200
            Re: open() and EOFError Grant Edwards <invalid@invalid.invalid> - 2014-07-08 14:19 +0000
              Re: open() and EOFError Terry Reedy <tjreedy@udel.edu> - 2014-07-08 11:08 -0400
              Re: open() and EOFError Tim Chase <python.list@tim.thechases.com> - 2014-07-08 10:20 -0500
              Re: open() and EOFError Chris Angelico <rosuav@gmail.com> - 2014-07-09 01:24 +1000
              Re: open() and EOFError Tim Chase <python.list@tim.thechases.com> - 2014-07-08 10:46 -0500
                Re: open() and EOFError Roy Smith <roy@panix.com> - 2014-07-08 21:05 -0400
                Re: open() and EOFError Anssi Saari <as@sci.fi> - 2014-07-10 22:40 +0300
              Re: open() and EOFError Chris Angelico <rosuav@gmail.com> - 2014-07-09 01:49 +1000
              Re: ^D vs ^Z as EOF and DOS dinosaurs talking (was: open() and EOFError) Tim Chase <python.list@tim.thechases.com> - 2014-07-08 10:57 -0500
                Re: ^D vs ^Z as EOF and DOS dinosaurs talking (was: open() and EOFError) Jan van den Broek <balglaas@xs4all.nl> - 2014-07-08 16:38 +0000
              Re: ^D vs ^Z as EOF and DOS dinosaurs talking (was: open() and EOFError) Chris Angelico <rosuav@gmail.com> - 2014-07-09 02:20 +1000
              Re: open() and EOFError Tim Chase <python.list@tim.thechases.com> - 2014-07-08 11:40 -0500
              Re: open() and EOFError Chris Angelico <rosuav@gmail.com> - 2014-07-09 02:50 +1000
          Re: open() and EOFError Steven D'Aprano <steve@pearwood.info> - 2014-07-08 09:03 +0000
            Re: open() and EOFError Chris Angelico <rosuav@gmail.com> - 2014-07-08 20:29 +1000
      Re: open() and EOFError Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-07-07 14:06 +0100
      Re: open() and EOFError Chris Angelico <rosuav@gmail.com> - 2014-07-07 23:27 +1000
      Re: open() and EOFError Chris Angelico <rosuav@gmail.com> - 2014-07-07 23:29 +1000
      Re: open() and EOFError Dan Stromberg <drsalists@gmail.com> - 2014-07-07 09:07 -0700
      Re: open() and EOFError Ian Kelly <ian.g.kelly@gmail.com> - 2014-07-07 11:25 -0600
        Re: open() and EOFError Marko Rauhamaa <marko@pacujo.net> - 2014-07-07 20:31 +0300
          Re: open() and EOFError Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-07-07 18:07 +0000
            Re: open() and EOFError Marko Rauhamaa <marko@pacujo.net> - 2014-07-07 21:42 +0300
            Re: open() and EOFError Roy Smith <roy@panix.com> - 2014-07-07 20:22 -0400
          Re: open() and EOFError Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-07-08 10:09 +1200
            Re: open() and EOFError Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-07-08 00:10 +0100
            Re: open() and EOFError "Neil D. Cerutti" <neilc@norwich.edu> - 2014-07-08 10:29 -0400
      Re: open() and EOFError Chris Angelico <rosuav@gmail.com> - 2014-07-08 03:29 +1000
        Re: open() and EOFError Marko Rauhamaa <marko@pacujo.net> - 2014-07-07 20:40 +0300
          Re: open() and EOFError Chris Angelico <rosuav@gmail.com> - 2014-07-08 10:55 +1000
      Re: open() and EOFError Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-07-07 18:54 -0400

csiph-web