On Fri, 20 Jun 2014 14:28:52 +0000, Grant Edwards wrote:

> On 2014-06-20, Mark Lawrence <breamore...@yahoo.co.uk> wrote:
>> For the OP a very important rule of thumb is never use a bare except,
>> so this is right out.
>> try:
>>      doSomething()
>> except:
>>      WTF()
> IMO, that sort of depends on WTF() does. One case where a bare except is
> well used is when stdandard output/error are not going anywhere useful
> and you want to log the exception and then terminate:
> try:
>     whatever()
> except Exception as e:
>     syslog("foobar: terminating due to unhandled exception %s.\n" % e)
>     sys.exit(1)
> Alternatively, if you're not at the top level in the call tree,
> sometimes it's useful to log an exception but still pass it on up in
> case somebody higher up wants to handle it:
> def asdf():
>     try:
>         whatever()
>     except Exception as e:
>         syslog("Function asdf() terminating due to exception %s.\n" % e)
>         raise

I think that is getting beyond the level of the O.P.
All guide lines may have exceptions but until you have developed enough 
to realise where they can be safely ignored it is best to follow them.

I was in Vegas last week. I was at the roulette table, having a lengthy
argument about what I considered an Odd number.
                -- Steven Wright

Reply via email to