Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeeder.ewetel.de!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.021 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'preferably': 0.03; 'rules.': 0.07; 'python': 0.08; 'both.': 0.16; 'cc:addr:python- list': 0.16; 'wrote:': 0.18; "they've": 0.18; 'cc:no real name:2**0': 0.21; "aren't": 0.21; 'header:In-Reply-To:1': 0.22; 'wonder': 0.23; 'preferred': 0.25; 'cc:2**0': 0.26; 'raise': 0.28; 'version,': 0.28; "i'm": 0.28; 'class': 0.29; 'print': 0.29; 'cc:addr:python.org': 0.29; 'cases': 0.32; "i've": 0.32; 'break': 0.32; 'there': 0.33; 'header:User-Agent:1': 0.33; 'it."': 0.34; 'try:': 0.34; '...': 0.35; 'form,': 0.35; 'enough': 0.38; 'should': 0.38; 'except': 0.39; 'special': 0.66; 'fulfils': 0.84; 'it"': 0.84; 'zen': 0.84 X-IronPort-AV: E=Sophos;i="4.73,570,1325458800"; d="scan'208";a="233094" X-Virus-Scanned: amavisd-new at zimbra.sequans.com Date: Mon, 12 Mar 2012 11:37:48 +0100 From: Jean-Michel Pichavant User-Agent: Mozilla-Thunderbird 2.0.0.24 (X11/20100328) MIME-Version: 1.0 To: bvdp Subject: Re: Raise X or Raise X()? References: <387014.2537.1331492695725.JavaMail.geo-discussion-forums@pbjv6> In-Reply-To: <387014.2537.1331492695725.JavaMail.geo-discussion-forums@pbjv6> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 1331548677 news.xs4all.nl 6913 [2001:888:2000:d::a6]:49112 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:21527 bvdp wrote: > Which is preferred in a raise: X or X()? I've seen both. In my specific case I'm dumping out of a deep loop: > > try: > for ... > for ... > for ... > if match: > raise StopInteration() > else ... > > except StopInteration: > print "found it" > I prefer the raise X() version, it fulfils the zen of python : "Special cases aren't special enough to break the rules. There should be one-- and preferably only one --obvious way to do it." I still wonder why they've added the class raise form, on which purpose. JM