Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #21527

Re: Raise X or Raise X()?

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 <prvs=411b6815e=jeanmichel@sequans.com>
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 <jeanmichel@sequans.com>
User-Agent Mozilla-Thunderbird 2.0.0.24 (X11/20100328)
MIME-Version 1.0
To bvdp <bob@mellowood.ca>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.583.1331548677.3037.python-list@python.org> (permalink)
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

Show key headers only | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Raise X or Raise X()? bvdp <bob@mellowood.ca> - 2012-03-11 12:04 -0700
  Re: Raise X or Raise X()? Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2012-03-11 21:37 +0100
    Re: Raise X or Raise X()? Chris Rebert <clp2@rebertia.com> - 2012-03-11 14:49 -0700
    Re: Raise X or Raise X()? Stefan Behnel <stefan_ml@behnel.de> - 2012-03-12 14:52 +0100
      Re: Raise X or Raise X()? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-03-12 15:08 +0000
        Re: Raise X or Raise X()? Stefan Behnel <stefan_ml@behnel.de> - 2012-03-12 17:08 +0100
  Re: Raise X or Raise X()? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-03-11 23:59 +0000
    Re: Raise X or Raise X()? bvdp <bob@mellowood.ca> - 2012-03-11 18:53 -0700
    Re: Raise X or Raise X()? MRAB <python@mrabarnett.plus.com> - 2012-03-12 02:26 +0000
  Re: Raise X or Raise X()? Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-03-12 11:37 +0100
  Re: Raise X or Raise X()? Robert Kern <robert.kern@gmail.com> - 2012-03-12 12:47 +0000
  Re: Raise X or Raise X()? James Elford <fil.oracle@gmail.com> - 2012-03-12 13:06 +0000
  Re: Raise X or Raise X()? Chris Angelico <rosuav@gmail.com> - 2012-03-13 00:13 +1100

csiph-web