Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'cpython': 0.05; 'instance,': 0.05; 'pointer': 0.05; 'warnings': 0.05; 'initialize': 0.07; 'exceptions': 0.09; 'match.': 0.09; 'proximity': 0.09; 'tuple': 0.09; 'api': 0.09; 'am,': 0.12; 'received:209.85.210.174': 0.13; 'received:mail- iy0-f174.google.com': 0.13; '(aka': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:syntax': 0.16; 'subject:question': 0.16; 'wrote:': 0.16; 'wed,': 0.17; "doesn't": 0.22; 'feb': 0.22; 'header:In-Reply-To:1': 0.22; 'url:dev': 0.23; 'code': 0.25; 'saying': 0.25; 'function': 0.27; 'message- id:@mail.gmail.com': 0.28; 'booth': 0.30; 'tuples': 0.30; 'does': 0.32; 'to:addr:python-list': 0.33; "we're": 0.34; 'nested': 0.34; 'null': 0.34; 'url:python': 0.36; 'similar': 0.36; 'received:google.com': 0.37; 'skip:_ 10': 0.37; 'received:209.85': 0.38; 'url:docs': 0.39; 'url:org': 0.39; 'received:209': 0.39; 'subject:: ': 0.39; 'to:addr:python.org': 0.40; 'carry': 0.62; 'absolutely': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=DdR9Uss5YOckwNNxr1OKxm5Ji6jLJqymIvaU61iYS6c=; b=XCe03PpGRb3J91qZE6l1yFG23znpskb1mSGb8okwmMytERtjUZopfXCYe4HomkGtYi 7rw/sllNd5uCZGzWuiQzef7X2rhZMDtfl6qfI7owrbezQq9yfPxqBuqpyxW28NsD51Si +ZIghwM8QDVjp04FPPEtDbHu7YHt3M6csn4DU= MIME-Version: 1.0 In-Reply-To: References: Date: Wed, 1 Feb 2012 11:53:48 +1100 Subject: Re: except clause syntax question From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1328057631 news.xs4all.nl 6909 [2001:888:2000:d::a6]:59278 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19668 On Wed, Feb 1, 2012 at 9:03 AM, Duncan Booth wrote: > Abitrarily nested tuples of exceptions cannot contain loops so the code > simply needs to walk through the tuples until it finds a match. Is this absolutely guaranteed? The C API for CPython provides: (Py2) http://docs.python.org/c-api/tuple.html#PyTuple_SetItem (Py3) http://docs.python.org/dev/c-api/tuple.html#PyTuple_SetItem which doesn't have massive warnings on it saying "USE THIS ONLY TO INITIALIZE A TUPLE" (compare, for instance, _PyTuple_Resize which does carry a similar warning). Is the assumption then that we're all adults, and that mutating a tuple is like passing a null pointer to an API function (aka "loaded gun in proximity to foot")? ChrisA