Calling e.args means that you can access the attributes of the exception object. But it won't catch BaseException or the system-exiting exceptions SystemExit, KeyboardInterrupt and GeneratorExit
Here is its sample:
try:
i = 1/0
print(i)
except Exception as e:
print (e.args)
This will print:
('division by zero')
More ever If we rasie BaseException error
try:
raise BaseException()
except Exception as e:
print (e.args)
The output will be like this
runfile('W:/Summerizer/except.py', wdir='W:/Summerizer')
Traceback (most recent call last):
File "<ipython-input-3-11e8f07e28c7>", line 1, in <module>
runfile('W:/Summerizer/except.py', wdir='W:/Summerizer')
File "C:\Users\adodhiwala\AppData\Local\conda\conda\envs\py35\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 668, in runfile
execfile(filename, namespace)
File "C:\Users\adodhiwala\AppData\Local\conda\conda\envs\py35\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "W:/Summerizer/except.py", line 10, in <module>
raise BaseException()
BaseException
Here as is used to access more functions(args,message etc) so you can understand error more efficiently.