Looking for a way to stop execution of script, in the script

Fredrik Lundh fredrik at pythonware.com
Tue Nov 14 13:47:59 EST 2006


Josh Bloom wrote:

> Hi everyone, I'm looking for a way to stop execution of a script from 
> within the script.
> 
> I'm familiar with this idiom:
> 
> While 1:
>   doFirstThing()
>   doSecondThing()
>   if something:
>     break
>   doThirdThing()
>   break

I'm not.  why are you using a while statement to execute the code once?

> doFirstThing()
> doSecondThing()
> if something:
>     die
> doThirdThing()

sys.exit() ?

(or if you prefer, "raise SystemExit")

</F>




More information about the Python-list mailing list