Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.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.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'tuple': 0.09; 'exception': 0.12; 'cc:addr:python-list': 0.15; 'mon,': 0.15; 'block,': 0.16; 'simplicity.': 0.16; 'subject:syntax': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'tuples,': 0.16; 'x).': 0.16; 'subject:question': 0.16; 'wrote:': 0.16; 'jan': 0.19; 'cc:no real name:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'appear': 0.23; 'formatting': 0.23; 'string': 0.24; 'cc:2**0': 0.25; 'pm,': 0.26; "i'm": 0.27; 'message-id:@mail.gmail.com': 0.28; 'cc:addr:python.org': 0.29; 'collections': 0.30; 'received:209.85.210.46': 0.30; 'received:mail- pz0-f46.google.com': 0.30; 'tuples': 0.30; 'regardless': 0.31; 'does': 0.32; 'agree': 0.33; 'match': 0.33; 'wondering': 0.34; 'something': 0.35; 'example,': 0.36; 'but': 0.37; 'received:google.com': 0.37; 'bunch': 0.38; 'steven': 0.38; 'received:209.85': 0.38; 'why': 0.39; 'except': 0.39; 'either': 0.39; 'received:209': 0.39; 'subject:: ': 0.39; 'might': 0.40; 'type': 0.60; 'more': 0.61; 'charles': 0.67; '30,': 0.74; '-0500,': 0.84; '7:00': 0.84; 'canonical': 0.91; 'lists:': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=/8gyqlcjC9MYuhV5TbXRbCGeKCd9AFo/chj83+ZkKA0=; b=J1d4qN2a1YBxHT9gLsIKPa0f/MyrObPEgBC5wWm3tu+g6vXchgSCqXIA17wDqDb4G0 DKXhGZWRDx51QSDgQPlsgu7dqwY5HhEAlu150UShyrwEV04PoE75t6fkLImgG0MwGX9F VgmIgj6Vs7KuZufNUWREK8HIkJxdC2F2/IcyU= MIME-Version: 1.0 In-Reply-To: <4f272f1f$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4f272f1f$0$29989$c3e8da3$5496439d@news.astraweb.com> From: Devin Jeanpierre Date: Mon, 30 Jan 2012 19:25:57 -0500 Subject: Re: except clause syntax question To: "Steven D'Aprano" Content-Type: text/plain; charset=UTF-8 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1327969600 news.xs4all.nl 6942 [2001:888:2000:d::a6]:40993 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19620 On Mon, Jan 30, 2012 at 7:00 PM, Steven D'Aprano wrote: > On Mon, 30 Jan 2012 12:41:00 -0500, Charles Yeomans wrote: > >> To catch more than one exception type in an except block, one writes >> >> except (A, B, C) as e: >> >> I'm wondering why it was decided to match tuples, but not lists: >> >> except [A, B, C] as e: > > Simplicity. > -snip- I agree with the snipped, but would also like to add that regardless of why it might be so, tuples do appear to be the canonical type for collections that need to be typechecked -- not just for except; it's a consistent thing that if you're going to do something with "X, or a bunch of X's", then it's either an X or a tuple of X's. For example, string formatting with % works this way, as does isinstance(a, X). -- Devin