Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3a.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.039 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'subject:error': 0.03; 'differently': 0.07; 'nested': 0.07; 'style.': 0.09; 'subject:files': 0.09; 'wrong,': 0.09; 'yeah,': 0.09; 'cc:addr :python-list': 0.11; '"file': 0.16; 'subject:handling': 0.16; 'subject:when': 0.16; 'cc:addr:python.org': 0.22; 'error': 0.23; 'cc:2**0': 0.24; 'possibly': 0.26; 'header:In-Reply-To:1': 0.27; 'wonder': 0.29; 'errors': 0.30; 'message-id:@mail.gmail.com': 0.30; 'thanks!': 0.32; 'open': 0.33; '(i.e.': 0.33; 'cases': 0.33; 'maybe': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'should': 0.36; 'two': 0.37; 'handle': 0.38; 'does': 0.39; 'how': 0.40; 'read': 0.60; 'most': 0.60; "you're": 0.61; 'times': 0.62; 'places': 0.64; 'deals': 0.65; 'to:addr:gmail.com': 0.65; 'between': 0.67; 'ending': 0.78; 'distinguish': 0.84; 'reading,': 0.84; 'dealt': 0.91; 'responses': 0.93 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:to :cc:content-type; bh=Fwe7II+HpRtdm3k61N7kA6HHU6k+otuz8swYtu31CRk=; b=USiXVGsSt7fU4BBYiUYiiP9QtpvPyEufeVtctrP/DW2NN2MTiSJ29SJsABOkKKfgk/ 4S1DHyb/FSNFIttB6Ywrc7LfbjTEw3t9k0HMNrbVozEjb38TCaBrz+BSJTvBjWVFBxEN MgPH5lztpL4VQQllNS2DCGCdxI4YFLY8RvIuHnOkGGllOM4bRbDPmP/D3URVLFN1qJ7H ktWlldl5OdBi1Nl5Uuyi0+o1XR5YxGJuGXiI5Q0qhGOqePjZD65iebg6WL9ZAxk+Xflk 2viIFJzq6p0yns3mqyePFRGLrYXFgNPprzjqUSjAPTBq1t0FOrRIooL+9Q4XSGsVDGjr fXtg== MIME-Version: 1.0 X-Received: by 10.182.20.68 with SMTP id l4mr13618341obe.51.1404935696392; Wed, 09 Jul 2014 12:54:56 -0700 (PDT) In-Reply-To: References: Date: Wed, 9 Jul 2014 21:54:56 +0200 Subject: Re: error handling when opening files From: Alex Burke To: Chris Angelico Content-Type: text/plain; charset=UTF-8 Cc: "python-list@python.org" 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1404935699 news.xs4all.nl 2938 [2001:888:2000:d::a6]:37591 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:74277 > If that's what you're expecting, then your message is wrong, because > you say "file never opened" - but you possibly DID open it, and maybe > read something from it. The choice between the two forms should be > based on whether you want to distinguish between errors on opening and > errors on reading, or conflate them as "file unreadable". There are > times and places for each style. Yeah, got you - most of the responses echoed that it comes down to what the error situations are and whether they genuinely can or cannot be dealt with in the same way. In the case where you do want to handle the cases differently (i.e. it was there but oh my the contents turned out to be garbage) it does make me wonder how you deals with that without ending up with nested try/catch - but perhaps that would be time to use functions to make it read better. Thanks!