According to How to exit from Python without traceback?, calling sys.exit()
in a Python script should exit silently without a traceback.
import sys
sys.exit(0)
However, when I launch my script from the command line on Windows 7 with python -i "exit.py"
, (or from Notepad++), a traceback for a SystemExit
exception is displayed.
U:\>python -i "exit.py"
Traceback (most recent call last):
File "exit.py", line 2, in <module>
sys.exit(0)
SystemExit: 0
>>>
Why is sys.exit()
displaying a traceback when run from the Windows command line?
(For reference, I am using Python 3.6.4 on Windows 7)
sys.exit()
is implemented. – BipackSystemExit
exceptions don't have tracebacks – Durbar