8 print(eval(string)) 9 except (KeyboardInterrupt, EOFError): 10 print() 11 exit()12 except (BaseException, KeyboardInterrupt) as e: 13 print(e) 14
quit functions don't exist at top-level if python is started with the
-S flag, and will raise an error. Use
quit functions are actually
site.Quitter objects and are loaded, at interpreter start up, from
However, if the interpreter is started with the
-S flag, or a custom
site.py is used then
quit may not be present.
It is recommended to use
sys.exit() which is built into the interpreter and is guaranteed to be present.
try: patch_diffs() except Exception as exc: print(exc) exit(1)
exit() is used and will fail if the python is run with the
import sys try: patch_diffs() except Exception as exc: print(exc) sys.exit(1)
sys.exit() is guaranteed to work, regardless of the interpreter options.