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


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

Re: Understanding and dealing with an exception

Started byMark Lawrence <breamoreboy@yahoo.co.uk>
First post2012-10-14 12:17 +0100
Last post2012-10-14 12:17 +0100
Articles 1 — 1 participant

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

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Understanding and dealing with an exception Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-10-14 12:17 +0100

#31248 — Re: Understanding and dealing with an exception

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2012-10-14 12:17 +0100
SubjectRe: Understanding and dealing with an exception
Message-ID<mailman.2174.1350213448.27098.python-list@python.org>
On 14/10/2012 11:06, Terry Reedy wrote:
> On 10/14/2012 4:20 AM, Mark Lawrence wrote:
>
>> You've already had some advice so I'll just point out that a bare except
>> is a bad idea as you wouldn't even be able to catch a user interrupt.
>> Try (groan!) catching StandardError instead.
>
> There are some bare except:s in the stdlib, that adding another is
> frowned on and removing one is smiled upon.
>
> However:
>  >>> StandardError
> Traceback (most recent call last):
>    File "<pyshell#0>", line 1, in <module>
>      StandardError
> NameError: name 'StandardError' is not defined
>
> Try:
>  >>> Exception
> <class 'Exception'>
>
> This catches everything except a few things like Keyboard Interrupt that
> you normally should not catch.
>
>  >>> BaseException
> <class 'BaseException'>
>
> This catches everything, but signals that doing so is probably intentional.
>

White Man type with forked fingers?

c:\Users\Mark\Cash\Python>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> StandardError
<type 'exceptions.StandardError'>

Perhaps not.

c:\Users\Mark\Cash\Python>py -3
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 
bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> StandardError
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
NameError: name 'StandardError' is not defined

Down to this http://www.python.org/dev/peps/pep-3151/ or was it done 
earlier?

-- 
Cheers.

Mark Lawrence.

[toc] | [standalone]


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


csiph-web