exit()
Gary Robinson
garyrob at mac.com
Mon Sep 8 13:46:08 EDT 2008
In Python 2.5.2, I notice that, in the interpreter or in a script, I can exit with:
exit()
But I don't see exit() mentioned as a built-in function; rather the Python Library Reference says we should use sys.exit(). Also, the reference says sys.exit() is like raising SystemExit. But so is just calling exit(). For instance,
exit('some error message')
has the same apparent effect as
raise SystemExit, 'some error message'.
Both return a status code of 1 and print the error string on the console.
Is exit() documented somewhere I haven't been able to find? Is there any reason to use sys.exit() given exit()'s availability?
If there is an advantage to sys.exit() over exit(), then does sys.exit() have any advantage over "raise SystemExit, 'some error message'" in cases where a module has no other reason to import sys?
--
Gary Robinson
CTO
Emergent Music, LLC
personal email: garyrob at mac.com
work email: grobinson at emergentmusic.com
Company: http://www.emergentmusic.com
Blog: http://www.garyrobinson.net
More information about the Python-list
mailing list