Stop python
Steve Purcell
stephen_purcell at yahoo.com
Mon Apr 16 04:47:10 EDT 2001
David V. wrote:
> Is it possible to stop parsing python program at some point, for
> example, like in shell script using ‘exit’?
Yes,
import sys
sys.exit()
Usually, though, you should instead structure your program into functions
that call each other. The program would exit when the top-level
function exits:
def main(): # top-level function
do_something() # another function
if not more_things_to_do():
return # the program exits by returning from the
# top-level function
do_more_things()
if __name__ == '__main__': # if this file is run as a script
main() # start the top-level function
-Steve
--
Steve Purcell, Pythangelist
Get testing at http://pyunit.sourceforge.net/
Any opinions expressed herein are my own and not necessarily those of Yahoo
More information about the Python-list
mailing list