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


Groups > comp.lang.python > #53411 > unrolled thread

Newbie: use of built-in exceptions

Started byRui Maciel <rui.maciel@gmail.com>
First post2013-09-01 12:17 +0100
Last post2013-09-02 18:32 +0100
Articles 3 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Newbie: use of built-in exceptions Rui Maciel <rui.maciel@gmail.com> - 2013-09-01 12:17 +0100
    Re: Newbie: use of built-in exceptions Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-09-01 13:26 +0200
      Re: Newbie: use of built-in exceptions Rui Maciel <rui.maciel@gmail.com> - 2013-09-02 18:32 +0100

#53411 — Newbie: use of built-in exceptions

FromRui Maciel <rui.maciel@gmail.com>
Date2013-09-01 12:17 +0100
SubjectNewbie: use of built-in exceptions
Message-ID<kvv7o7$1ek$1@dont-email.me>
Are there any guidelines on the use (and abuse) of Python's built-in exceptions, telling where 
it's ok to raise them and where it's preferable to define custom exceptions instead?  


Thanks in advance,
Rui Maciel

[toc] | [next] | [standalone]


#53412

FromChris “Kwpolska” Warrick <kwpolska@gmail.com>
Date2013-09-01 13:26 +0200
Message-ID<mailman.445.1378034792.19984.python-list@python.org>
In reply to#53411
On Sun, Sep 1, 2013 at 1:17 PM, Rui Maciel <rui.maciel@gmail.com> wrote:
> Are there any guidelines on the use (and abuse) of Python's built-in exceptions, telling where
> it's ok to raise them and where it's preferable to define custom exceptions 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.

-- 
Chris “Kwpolska” Warrick <http://kwpolska.tk>
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense

[toc] | [prev] | [next] | [standalone]


#53513

FromRui Maciel <rui.maciel@gmail.com>
Date2013-09-02 18:32 +0100
Message-ID<l02i46$gd7$1@dont-email.me>
In reply to#53412
Chris “Kwpolska” Warrick wrote:

> 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.

Ok, thanks for the tip.


Rui Maciel

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web