In the subsequent you can get to the attributes of the exception object:
>>> def catch():
... try:
... asd()
... except Exception as e:
... print e.message, e.args
...
>>> catch()
global name 'asd' is not defined ("global name 'asd' is not defined",)
However, it doesn't get BaseException or the framework leaving exceptions SystemExit, KeyboardInterrupt, and GeneratorExit:
>>> def catch():
... try:
... raise BaseException()
... except Exception as e:
... print e.message, e.args
...
>>> catch()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in catch
BaseException
Where a bare except does:
>>> def catch():
... try:
... raise BaseException()
... except:
... pass
...
>>> catch()
>>>
See the Built-in Exceptions segment of the docs and the Errors and Exceptions part of the instructional exercise for more information.
Are you interested to learn the concepts of Python? Join the python training course fast!