[Tutor] keyboard interrupt
Jim Mooney
cybervigilante at gmail.com
Thu May 23 22:37:38 CEST 2013
> Apparently Wing isn't as savvy as IDLE when it comes to communicating
> with the subprocess. I've only searched for about a minute, but
> apparently the way this works in Wing is to "Restart Shell":
>
> http://stackoverflow.com/a/10360503/205580
> http://www.wingware.com/doc/debug/interactive-python-shell
>
> This kills the suprocess and starts a new interpreter. Crude, but it
> should get the job done.
Thanks. I'll put stackoverflow on my bookmarks. There is still a
difference, though. The program (as corrected below) prints out the
last sound heard as a hearing test, if you press Ctrl-C in Idle or the
Windows Command Console, but prints nothing if you use Option >
Restart Shell in Wing 101. Here's the corrected program if anyone
wants to test their hearing ;')
Oh, as a tip for winusers who have avoided the Win command console, I
also did because I thought you had to type in one line at a time. I
just found I can right-click > paste an entire Py program in (after
you start Python). The prog then starts after you hit Enter twice.
This is Win 7.
import winsound
try:
for freq in range(100,32000,100):
winsound.Beep(freq, 1000)
except KeyboardInterrupt:
print 'last frequency heard was', freq - 100
exit(0)
--
Jim Mooney
More information about the Tutor
mailing list