Skip to content
Advertisement

Using sys.exit or SystemExit; when to use which?

Some programmers use sys.exit, others use SystemExit.

  1. What is the difference?
  2. When do I need to use SystemExit or sys.exit inside a function?

Example:

JavaScript

or:

JavaScript

Advertisement

Answer

No practical difference, but there’s another difference in your example code – print goes to standard out, but the exception text goes to standard error (which is probably what you want).

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement