[Tutor] Please critique my Fraq.py
Dick Moores
rdm at rcblue.com
Sun Jul 25 12:20:18 CEST 2004
At 02:44 7/25/2004, Brian van den Broek wrote:
>>""
>>At two points in the inner loop I've got a break. But I need another at
>>the end of the outer loop to get out smoothly.
>>Thanks,
>>Dick Moores
>
>Hi Dick,
>
>I haven't followed your thread closely so I don't recall your program.
>Thus, it might not meet your definition of "smooth" in the case at hand,
>but have you tried sys.exit() ?
Brian,
Yes! I modified that silly test/game script to:
import sys
"""
print "This is an appropriate response test."
print "Enter q or x to give up."
while True:
while True:
answer = raw_input("How are you today: ")
if answer == "x":
print "Give up? O.K., you can try again tomorrow."
sys.exit()
elif answer != "Fine, thank you. And you?":
print "C'mon. That's dumb. Try again."
else:
print "Congratulations! You passed the test!"
sys.exit()
"""
Until yesterday, when tutors taught me the wonders of the Win XP command
line, I was testing scripts only on IDLE. On IDLE, sys.exit() employed as
above gets a big red
Traceback (most recent call last):
File "C:/Python23/DumbTest2.py", line 10, in -toplevel-
sys.exit()
SystemExit
Executing via the command line gets a smooth quit.
This is the second time in a couple of weeks that IDLE has failed to
execute code correctly. The first was when I was trying to use
msvcrt.getch().
Whew! Guess I should stick just with the command line for execution of
scripts from now on.
Thanks,
Dick
More information about the Tutor
mailing list