[Tutor] Exit from a Program While in IDLE

Alan Gauld alan.gauld at btinternet.com
Fri Sep 5 10:27:44 CEST 2008


"Wayne Watson" <sierra_mtnview at sbcglobal.net> wrote

> seems liking quitting, exiting, or stopping a program is a
> bit controversial. I've tried using sys.exit(0) while debugging
> a program in IDLE, but it asks if I really want to exit.

Thats because IDLE is an IDE so it interceprts the exit
(actually it intercepts the esception that exit() generates)
Thats what you want otherwise you'd constantly have to
restart IDLE. But when you run your program for
real - from Windows explorer for example it will just exit.

> I just want a no-fuss, no-muss way of exiting the code
> in the same fashion that when I get to the last line,
> it exits next. Win XP, Python 2.4.

sys.exit() will do that when you run the program standalone.

If its a GUI program in Tkinter you can also use the root
quit command to quit the GUI mainloop which usually exits
the program too. But testing Tkinter programs from within
IDLE(which is itself a Tkinter program) has always been
a wee bit tricky, its better to always do your final test run
outside of IDLE IMHO. After all thats how the program
will eventually be used!

HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld


>
> -- 
>
>           Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
>
>             (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
>              Obz Site:  39° 15' 7" N, 121° 2' 32" W, 2700 feet
>
>          Interesting government experience prior their candidacy:
>
>             Abraham Lincoln: 2 years; George Washington: 0 years;
>              Dwight Eisenhower: 0 years; James Buchanan: 29 years*
>                 Barack Obama: 11 years; John McCain: 26 years
>
>              * Not a particularly good president at all
>
>                    Web Page: <www.speckledwithstars.net/>


--------------------------------------------------------------------------------


> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 




More information about the Tutor mailing list