osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

revisiting the "What am I running on?" question


On 2019-02-19, Chris Angelico <rosuav at gmail.com> wrote:

> Oh, and not just bugs either. If the user hits Ctrl-C at just the
> right moment, KeyboardInterrupt will be raised. You'll swallow that
> exception silently, preventing the user-requested halt, and going and
> doing the wrong thing. Don't use a bare except clause even if your
> code is 100% perfect every time. (And anyone who thinks their code is
> perfect hasn't tested it.)

IMO, you're allowed to use a bare except clause to do cleanup or
logging as long as the execption handler ends with the line

   raise

Something like this:

-- 
Grant Edwards               grant.b.edwards        Yow! I just went below the
                                  at               poverty line!
                              gmail.com