exit()

G

Gary Robinson

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: (e-mail address removed)
work email: (e-mail address removed)
Company: http://www.emergentmusic.com
Blog: http://www.garyrobinson.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,470
Messages
2,571,809
Members
48,797
Latest member
PeterSimpson
Top