Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.062 X-Spam-Evidence: '*H*': 0.88; '*S*': 0.00; 'sure,': 0.09; "wouldn't": 0.14; 'blocks': 0.16; 'distinct': 0.16; 'wrote:': 0.18; 'normally': 0.19; 'case.': 0.24; 'mon,': 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; 'to:addr:python-list': 0.38; 'expect': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'easy': 0.60; 'more': 0.64; 'jul': 0.74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=AlMuHn4dZcqP0gPHpy0L24WTVTB3k3rSN799KfKpj4A=; b=lic+xoT5BMT8eWeSf+rQYSmeaQl+nyA5ABUKHvxUtvVPhgobq60+Fn/enTBolSPpwy 3qAIVxTRax/J2cxCZiB/gAEFModSbF6dcWB2CuAcWao8pwo16CSfMKuJ3pU4B4Sxk2Ak BF0IiB3J74MUJMO/zJZdQLBg5kMJVL1Rrok8s6piYytnmq4HjSHl65XfvBOU7mb2K0qx 71IDL5s9eD9Qy+qf5YHkqDWkw1QbnKsO4vJB+WlUIYd7XCBLjFOpeBlUk3BJfff8NGLA PGaGR5LgQnpWXPikaL9BZkaREFlf1FhAqKbJB4cAgwl9DPTb5TgKCRCo6V1CNF4/wmnD PInw== X-Received: by 10.68.90.68 with SMTP id bu4mr29685300pbb.5.1404753977395; Mon, 07 Jul 2014 10:26:17 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> From: Ian Kelly Date: Mon, 7 Jul 2014 11:25:36 -0600 Subject: Re: open() and EOFError To: Python 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: 11 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1404753981 news.xs4all.nl 2881 [2001:888:2000:d::a6]:52445 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:74127 On Mon, Jul 7, 2014 at 2:09 AM, Chris Angelico 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.