Looking for a way to stop execution of script, in the script
Josh Bloom
joshbloom at gmail.com
Tue Nov 14 13:52:29 EST 2006
Thanks Fredrik, yeah the while loop for single run is pretty stupid.
sys.exit() thats the call I was looking for.
-Josh
On 11/14/06, Fredrik Lundh <fredrik at pythonware.com> wrote:
>
> 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>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20061114/cb9f78c4/attachment.html>
More information about the Python-list
mailing list