exit()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gary Robinson

    exit()

    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@mac.com
    work email: grobinson@emerg entmusic.com
    Company: http://www.emergentmusic.com
    Blog: http://www.garyrobinson.net
Working...