Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.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.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'output': 0.05; 'utf-8': 0.07; 'preferable': 0.09; 'cc:addr:python-list': 0.11; 'exceptions,': 0.16; 'fits': 0.16; 'incorrect': 0.16; 'instead:': 0.16; 'rules.': 0.16; 'valueerror': 0.16; 'exception': 0.16; 'wrote:': 0.18; "python's": 0.19; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'define': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'raise': 0.29; 'message-id:@mail.gmail.com': 0.30; 'exceptions': 0.31; 'sep': 0.31; 'sense': 0.34; 'common': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'should': 0.36; 'pm,': 0.38; 'from:charset:utf-8': 0.61; 'telling': 0.64; 'skip:\xe2 10': 0.65; 'to:addr:gmail.com': 0.65; '8bit%:43': 0.74; 'url:tk': 0.95; '2013': 0.98 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:to :cc:content-type:content-transfer-encoding; bh=DUzfyN1bIOxKtuYcqeSuOghCfo43IuRyqjnoVGxpuE8=; b=W5aR8TfXfQ3v++Oa/vr6S8cq+hbBFPAWENjp7Q3SLUaGFUV+GnGWjoa5DNj+HmzzWq CeTB1rAKAQii7yqFBeKS4LynHISyk6VFbcsxnOmQ9eVQsDo81RqOtPsu/Rpc43p9itTL ikFUeCVTCXjs6fsTta7QKMBbCL+35fX6tc30oDqHIFJWPRMMwZAjsLLkKO8IctOyFCSd h0z8KsozO2jme4ArIuNDjPOguvk5g0C/RG0KV7btgU8OQWiixpsa86Esb0OCivvPUlTQ 4IsyPSTe9qdTafG9jDXAeLIvkcSjKTL8DLUEopqih2LxPJuaruIGSZpC/N+UN8NPWyHY Q8WA== MIME-Version: 1.0 X-Received: by 10.58.106.82 with SMTP id gs18mr17747113veb.18.1378034790710; Sun, 01 Sep 2013 04:26:30 -0700 (PDT) In-Reply-To: References: Date: Sun, 1 Sep 2013 13:26:30 +0200 Subject: Re: Newbie: use of built-in exceptions From: =?UTF-8?B?Q2hyaXMg4oCcS3dwb2xza2HigJ0gV2Fycmljaw==?= To: rui.maciel@gmail.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1378034792 news.xs4all.nl 15969 [2001:888:2000:d::a6]:55068 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:53412 On Sun, Sep 1, 2013 at 1:17 PM, Rui Maciel wrote: > Are there any guidelines on the use (and abuse) of Python's built-in exce= ptions, telling where > it's ok to raise them and where it's preferable to define custom exceptio= ns instead? There are no rules. You should use common sense instead: if the exception fits your needs (eg. ValueError when incorrect output occurs) then use it. --=20 Chris =E2=80=9CKwpolska=E2=80=9D Warrick PGP: 5EAAEA16 stop html mail | always bottom-post | only UTF-8 makes sense