Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '(at': 0.04; 'yet.': 0.04; 'matches': 0.07; 'indication': 0.09; 'literal': 0.09; 'okay': 0.09; 'cc:addr:python-list': 0.11; 'assume': 0.14; 'chained': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'tuple': 0.16; 'tuples,': 0.16; ':-)': 0.16; 'wrote:': 0.18; "python's": 0.19; '>>>': 0.22; 'programming': 0.22; 'putting': 0.22; 'cc:addr:python.org': 0.22; 'error': 0.23; "haven't": 0.24; 'cc:2**0': 0.24; 'suggested': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'raise': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'that.': 0.31; 'another': 0.32; 'cases': 0.33; 'could': 0.34; 'subject:with': 0.35; 'agree': 0.35; 'point.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'consistent': 0.36; 'in.': 0.36; 'useful': 0.36; 'effort': 0.37; '12,': 0.39; 'catch': 0.60; 'ian': 0.60; 'simply': 0.61; "you're": 0.61; 'here': 0.66; '2015': 0.84; 'alternative.': 0.84; 'subject:..': 0.84; '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=SQNy1rWON2M4JyCiy2ghL3qjFUXZFXlaBEFbKvrvEJo=; b=0mCJekPukMGuW+7wkWywexbgo9t0285xiUeN1XonAtMsxoWU3ZFWf7Vu8OnL4PqCNf iwSm9D/1+fEf7MDhYcdSlF+jzTnL0nzVq6nqLJsPoL9XjxTAoSUi3ZT4OwPvgDbCJWyI bY5J81qraxEnLL+Hdz4d7jbEZrvbsE+tnzulIB+1/aHIpmrouQvYSx2ktQMK8AUaANT/ YqiXO0jJAFiffOHHcdBBxilPjyo7751oAnK/G2YvC38Kp3IjCPhVtXecwNp2eOaYvFRI CL6tobuf5NyyuUII1jrFtd+iXKNCESVCqLl/A2nElgVj8xyiybZBLgFJxTRw2xNHCmGx 5T7A== MIME-Version: 1.0 X-Received: by 10.50.131.196 with SMTP id oo4mr6729007igb.2.1428782735070; Sat, 11 Apr 2015 13:05:35 -0700 (PDT) In-Reply-To: References: <5528feec$0$13002$c3e8da3$5496439d@news.astraweb.com> Date: Sun, 12 Apr 2015 06:05:34 +1000 Subject: Re: try..except with empty exceptions From: Chris Angelico Cc: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1428782737 news.xs4all.nl 2882 [2001:888:2000:d::a6]:35579 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:88840 On Sun, Apr 12, 2015 at 6:04 AM, Chris Angelico wrote: > On Sun, Apr 12, 2015 at 4:49 AM, Ian Kelly wrote: >> On Apr 11, 2015 5:06 AM, "Steven D'Aprano" >> wrote: >>> >>> Yes, I agree that Python's behaviour here is better than the alternative. >>> Having "except ()" catch nothing is consistent with the behaviour with >>> other tuples, so I'm okay with that. But it still surprised me :-) >> >> There's another alternative that I haven't seen suggested yet. An empty >> tuple could be considered an indication of a programming error and raise a >> chained ValueError. > > Not really a lot of point. Just as with isinstance, an empty tuple > simply matches nothing. Why go to the effort of rejecting it? (At least, I assume you're not putting a literal empty tuple in. This would be useful only in cases where the tuple is provided dynamically.) ChrisA