[Tutor] Controlling Where My Program Ends
alan.gauld at freenet.co.uk
Thu Jun 16 22:53:30 CEST 2005
> >>Never mind. I found it - sys.exit()
You can do the same thing by
This avoids the need to import sys...
> >>Sorry to have wasted the bandwidth/time.
> > This was in reference to a post about exiting from a program. I
> > figure out why my program wouldn't let me exit from within a
sub-menu of the
> > console interface. Since my webmail client goofed up the "from"
> > never showed up, and I've cancelled it to avoid wasting everyone's
> > further. I found sys.exit() in the library reference, which allows
me to do
> > what I want.
> > Don
> If you use the if __name__ == '__main__': idiom, then you can just
> instead of sys.exit()
> def main():
> lotsa interesting python code
> if somethinorother:
> # sys.exit()
> more interesting python code
> if __name__ == '__main__':
More information about the Tutor