Exceptions' Behaviour

Martin Sjögren martin at strakt.com
Thu Jul 19 03:09:30 EDT 2001


On Wed, Jul 18, 2001 at 11:58:43AM -0700, Tom Good wrote:
> Martin Sj?ren <martin at strakt.com> wrote in message news:<mailman.995459309.19355.python-list at python.org>...

[snipped my own code]

> Consider this:
> 
> PythonWin 2.1 (#15, Jun 15 2001, 14:13:47) [MSC 32 bit (Intel)] on
> win32.
> Portions Copyright 1994-2001 Mark Hammond (MarkH at ActiveState.com) -
> see 'Help/About PythonWin' for further copyright information.
> >>> # raise A,B raises A with B as its argument
> >>> raise "a", "b"
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in ?
> a: b
> >>> #raise (A, B) raises A and ignores B
> >>> raise ("a", "b")
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in ?
> a
> 
> 
> 
> Keep in mind also, that a statement like:
> 
>   except (A, B):
> 
> means to catch either A or B.  That is, it does NOT mean to catch the
> tuple (A,B).

Yes I know that, but that's not what I'm asking. What I'm asking is why in

>>> raise ("a","b")

the "b" disappears? IMO that's a pretty weird behaviour. Yes anybody using
non-class exceptions derived from Exception in a real-world program are
insane, but this is a puristic thing of mine. :-)

Martin

-- 
Martin Sjögren
  martin at strakt.com              ICQ : 41245059
  Phone: +46 (0)31 405242        Cell: +46 (0)739 169191
  GPG key: http://www.strakt.com/~martin/gpg.html




More information about the Python-list mailing list