exit a program gracefully
Chris Rebert
clp2 at rebertia.com
Mon May 4 18:14:53 EDT 2009
On Mon, May 4, 2009 at 3:02 PM, <Robert.T.Lynch at seagate.com> wrote:
>
> In a python program I ask if the user wants to continue. If they answer
> 'no', what options do I have to halt execution? I can put the rest of the
> code inside an "if bContinue:" block, but that seems awkward. I have looked
> at raising an exception, and perhaps this is the preferred method, but it
> seems daunting to my non-OOP eyes. Thanks -- Rob
There's the C-like:
from sys import exit
exit(return_code)
Or if you prefer exceptions, the standard way is:
raise SystemExit
Cheers,
Chris
--
http://blog.rebertia.com
More information about the Python-list
mailing list