I was writing a Python tutorial in Jupyter Notebook and was trying to demonstrate why one should never use a bare except
. My example was
try:
exit(0)
except:
print('Did not exit')
The idea was that exit
would raise a SystemExit
which inherits from BaseException
. However, the kernel still died when I ran the cell.
Running this code in IPython displays
Did not exit
What does exit
do in Jupyter Notebook?