469,287 Members | 2,637 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,287 developers. It's quick & easy.

program termination and return value

Hi,

Python novice. (But getting better.)

How do I terminate/quit my program during execution if I reach a point
where I desire to terminate the program?

How do I pass back an integer indicating (as example) an error number?

If I then do this, what do I put on the last line of my program to
return (for example) a zero, indicating success?

Thanks,
Scott
Jul 18 '05 #1
1 1436
On 8 Oct 2004 13:20:51 -0700, Scott Carlson <sc******@omnimn.com> wrote:
Hi,

Python novice. (But getting better.)

How do I terminate/quit my program during execution if I reach a point
where I desire to terminate the program? raise SystemExit
How do I pass back an integer indicating (as example) an error number? raise SystemExit(2) # error number 2
If I then do this, what do I put on the last line of my program to
return (for example) a zero, indicating success? noting : an equivalent to sys.exit(0) or raise SystemExit(0) is
automatically generated.
Thanks,
Scott

You can also use :
import sys
sys.exit(0)

on the python prompt :
import atexit
help(atexit)

good reading!
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Mahmood Ahmad | last post: by
92 posts views Thread by Raghavendra R A V, CSS India | last post: by
5 posts views Thread by Seong-Kook Shin | last post: by
5 posts views Thread by Daud | last post: by
17 posts views Thread by Gladiator | last post: by
19 posts views Thread by centurian | last post: by
8 posts views Thread by Scorpio | last post: by
9 posts views Thread by ehabaziz2001 | last post: by
1 post views Thread by twin2003 | last post: by
3 posts views Thread by twin2003 | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.