[Tutor] sys.exit help

Hugo Arts hugo.yoshi at gmail.com
Sun Aug 1 22:35:16 CEST 2010


On Sun, Aug 1, 2010 at 10:26 PM, Jason MacFiggen <jmacfiggen at gmail.com> wrote:
> I was wondering how can I change sys.exit so if you use command line to run
> the program. it prompts a message asking if the user wants to exit instead
> of automatically just exiting?

You can't change sys.exit, but you can build something yourself. You
have raw_input to ask the user something, and an if statement to make
a decision based on that input. You should be able to figure something
out.

One other point: if you just want to exit, you don't have to call
sys.exit really, you can just let the script end naturally (break out
of the while loop and it'll end by itself). sys.exit is only really
useful if you want a special exit status.

Hugo


More information about the Tutor mailing list