program termination and return value

S

Scott Carlson

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
 
F

F. Petitjean

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top