Python Forum
name of exception for exit()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
name of exception for exit()
#2
https://docs.python.org/3/library/except...SystemExit Wrote:exception SystemExit
This exception is raised by the sys.exit() function. It inherits from BaseException instead of Exception so that it is not accidentally caught by code that catches Exception. This allows the exception to properly propagate up and cause the interpreter to exit. When it is not handled, the Python interpreter exits; no stack traceback is printed. The constructor accepts the same optional argument passed to sys.exit(). If the value is an integer, it specifies the system exit status (passed to C’s exit() function); if it is None, the exit status is zero; if it has another type (such as a string), the object’s value is printed and the exit status is one.

A call to sys.exit() is translated into an exception so that clean-up handlers (finally clauses of try statements) can be executed, and so that a debugger can execute a script without running the risk of losing control. The os._exit() function can be used if it is absolutely positively necessary to exit immediately (for example, in the child process after a call to os.fork()).

code
The exit status or error message that is passed to the constructor. (Defaults to None.)
Reply


Messages In This Thread
name of exception for exit() - by Skaperen - May-24-2019, 05:58 PM
RE: name of exception for exit() - by Yoriz - May-24-2019, 06:06 PM
RE: name of exception for exit() - by Skaperen - May-24-2019, 07:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python difference between sys.exit and exit() mg24 1 1,998 Nov-12-2022, 01:37 PM
Last Post: deanhystad
  During handling of the above exception, another exception occurred Skaperen 7 27,171 Dec-21-2018, 10:58 AM
Last Post: Gribouillis
  How to exit after a try exception? Raptor88 11 58,018 Mar-05-2017, 08:56 AM
Last Post: Raptor88

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020