Checking for an exception
D'Arcy Cain
darcy at VybeNetworks.com
Sun Jun 25 12:48:43 EDT 2017
On 06/25/17 12:10, Steve D'Aprano wrote:
> py> isinstance(KeyboardInterrupt(), Exception)
> False
> py> isinstance(ValueError, Exception)
> False
That's because KeyboardInterrupt is not a subclass of Exception. If you
want to catch that as well you need to check against BaseException.
https://docs.python.org/3.6/library/exceptions.html#exception-hierarchy
--
D'Arcy J.M. Cain
Vybe Networks Inc.
http://www.VybeNetworks.com/
IM:darcy at Vex.Net VoIP: sip:darcy at VybeNetworks.com
More information about the Python-list
mailing list