[Tutor] Exit from program early

Roy Bleasdale royb at ubiquity.com.au
Fri Nov 4 08:13:49 CET 2005


Hi

In the example below I would like the program to stop if I forgot to 
provide an argument . Though I could do all my processing indented under 
the else statement, I was wondering if there was a command that would allow 
me to halt the program execution early.

Regards,

Roy


# Example program - Test for valid argument

import sys

if len(sys.argv) < 2:
     print "opps missing an argument"
     # Nice if I could stop and exit program here
else:
     print "Argument provided!!"
     # Looking good so go do some stuff

print "Done some stuff"



More information about the Tutor mailing list