[Tutor] Please critique my Fraq.py

Dick Moores rdm at rcblue.com
Sun Jul 25 13:45:16 CEST 2004


At 03:49 7/25/2004, Brian van den Broek wrote:

>Hi Dick,
>
>glad that helped :-)
>
>I don't know much about msvcrt.getch(). But for sys.exit(), I don't think
>it is right the IDLE is dong it 'wrong'.
>
>IDLE is configured to display all exceptions in the interactive window.
>sys.exit() ends programs by raising the SystemExit exception, and IDLE
>displays it, as it should with exceptions.

By executing scripts using IDLE, I didn't mean at the interactive prompt. 
I should have made that clear. I meant I write a script using a new IDLE 
window that I get by ^N. Then I would test it by saving the script, not 
closing it, and execute it by F5. It's when executing this way that 
sys.exit() does not work "correctly", i.e., does not permit me to use it 
to exit smoothly (silently?), the way I've written the code to do.

I do use the IDLE interactive prompt to test bits of code, but not a 
whole script.

Does this straighten out what I meant?

>IDLE could be coded to let SystemExit exceptions silently terminate your
>script. But I think that in a more complicated case than your program this
>could make it harder for you to figure out why your program terminated.
>Worse yet, imagine you imported a package and hadn't read the source (or
>couldn't if it was in C and like me, you can't make use of C-source yet).
>If it raised a SystemExit and IDLE didn't tell you, you'd have quite a
>puzzle working out why your script stopped. With the exception, you at
>least have a better starting point than "it stopped. I wonder why?" ;-)
>(import this #2).

Yes, I see your point.

>Also, since it is a Tkinter program, you shouldn't run Tkinter scripts via
>IDLE -- IDLE can't sort out which Tkinter things are meant for it and
>which for your script.

I've already experienced that with some Tkinter scripts.

Thanks again,

Dick 



More information about the Tutor mailing list