Subject:
Re: [Tutor] Controlling Where My Program Ends
From:
Don Parris <webdev (AT) matheteuo (DOT) org>
Date:
Tue, 14 Jun 2005 23:03:59 -0400
To:
tutor (AT) python (DOT) org
To:
tutor (AT) python (DOT) org
Wed, 15 Jun 2005 00:59:24 -0000
"DC Parris" <webdev (AT) matheteuo (DOT) orgwrote:
>>Never mind. I found it - sys.exit()
>>
>>Sorry to have wasted the bandwidth/time.
This was in reference to a post about exiting from a program. I couldn't
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" header, it
never showed up, and I've cancelled it to avoid wasting everyone's time
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 use return
instead of sys.exit()
def main():
lotsa interesting python code
if somethinorother:
# sys.exit()
return
more interesting python code
if __name__ == '__main__':
main()
Tutor maillist - Tutor (AT) python (DOT) org