import sys
def main():
print 'exiting'
sys.exit()
try:
main()
except SystemExit:
pass
> I suspect I may need to use exceptions, but I'm hoping
> not to need them. Thanks.
Use the Exceptions!
--
http://mail.python.org/mailman/listinfo/python-list
Russ wrote:
> I wrote a simple little function for exiting with an error message:
>
> def error ( message ): print_stack(); exit ("\nERROR: " + message +
> "\n")
>
> It works fine for executing as a script, but when I run it
> interactively in the python interpreter it kills the interpreter.
> Th
Terry Reedy wrote:
> How? In the standard interpreter, 'exit' is bound to the string
> 'Use Ctrl-Z plus Return to exit.'
> so trying to call it as a function fails.
I'm _presuming_ there was a hidden `from sys import *` in there. Hence
calling exit with the string (the help for sys.exit shows
"Terry Reedy" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> How? In the standard interpreter, 'exit' is bound to the string
> 'Use Ctrl-Z plus Return to exit.'
This is, of course, Windows specific. Other systems have other strings.
--
http://mail.python.org/mailman/listin
"Russ" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>I wrote a simple little function for exiting with an error message:
>
> def error ( message ): print_stack(); exit ("\nERROR: " + message +
> "\n")
>
> It works fine for executing as a script,
How? In the standard interpreter,
I wrote a simple little function for exiting with an error message:
def error ( message ): print_stack(); exit ("\nERROR: " + message +
"\n")
It works fine for executing as a script, but when I run it
interactively in the python interpreter it kills the interpreter.
That's not what I want. Is the