Re: [Tutor] keyboard interrupt

2013-10-17 Thread Bill

I know, way late to the party...

Did you try Ctrl-Break? In Windows that is usually how you interrupt a
program...



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-10-17 Thread Tim Golden
On 17/10/2013 16:36, Bill wrote:
 
 I know, way late to the party...
 
 Did you try Ctrl-Break? In Windows that is usually how you interrupt a
 program...

Take consolation from the fact that your five-month delay in replying
isn't even close to the longest delay I've seen on a Python list.

Someone responded, quite coherently and usefully, to a thread which fell
within my area of competence. But I hadn't seen the original post go
past. I queried the list as to whether there were delivery delays, and
someone pointed out that the answer was responding to a post from some
*six years* previously! (Which I think I'd answered at the time).

TJG


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-26 Thread Marc Tompkins
On Fri, May 24, 2013 at 7:19 PM, Steven D'Aprano st...@pearwood.infowrote:

You can edit *other* people's questions and answers??!??!??

 What. The. Hell.


The idea is to build an authoritative information resource (in particular,
the goal is that the accepted answer to any given question will become the
primary result for someone Googling that same question.)  So it makes very
good sense that both questions and answers can be edited for quality, and
the result is (mostly) good.

My objection is to people gaming the system - making imperceptible edits
like dashes-to-em-dashes - in order to juice their scores.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-26 Thread Steven D'Aprano

On 26/05/13 17:57, Marc Tompkins wrote:

On Fri, May 24, 2013 at 7:19 PM, Steven D'Aprano st...@pearwood.infowrote:

You can edit *other* people's questions and answers??!??!??


What. The. Hell.



The idea is to build an authoritative information resource (in particular,
the goal is that the accepted answer to any given question will become the
primary result for someone Googling that same question.)  So it makes very
good sense that both questions and answers can be edited for quality, and
the result is (mostly) good.


That's all very well and good when you're dealing with a system like Wikipedia, 
where edits belong to the entire community, not the person who merely made the 
edit. But Stackoverflow is specifically in the form of Question/Answer, where 
both questions and answers are labelled as belonging to the person who made 
them. Stackoverflow has the form of a conversation, with questions and 
*replies*. How can you judge the quality of a response when you cannot be sure 
that the question you are reading is the same question that was answered? Your 
reputation depends on the relevance of your reply. Change the question, and 
your perfectly sensible, helpful reply may look like an idiot's waffling:


Q: How do I sort a list without using any built-in functions or methods?
A: Start at this Wikipedia page, where many different sort-algorithms are 
listed.


# Question gets edited.
Q: How do I count the number of 0's, 1's and 2's in a list without using any 
built-in functions or methods?
A: Start at this Wikipedia page, where many different sort-algorithms are 
listed.


And now I look like a first degree moron. By the way, I am not making this 
scenario up. Read this thread starting here:

http://mail.python.org/pipermail/python-list/2013-May/647400.html



My objection is to people gaming the system - making imperceptible edits
like dashes-to-em-dashes - in order to juice their scores.


So these edits aren't default-deny, but default-accept? Worse and worse.




--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-26 Thread eryksun
On Sun, May 26, 2013 at 4:34 AM, Steven D'Aprano st...@pearwood.info wrote:

 So these edits aren't default-deny, but default-accept? Worse and worse.

It shows who made the edit and when they edited it, which links to the
revision history. When a question is closed it shows who voted to
close it. Even retagging shows up in the revision history. Also, since
it requires a rep of 2000 to edit, generally the system isn't abused.
Lower-rep users can suggest an edit, but that goes through a review
process.

You're notified when someone edits your answer, and you can roll it
back to a previous version. However, too many edits causes your post
to become community wiki (I think 10 edits by the owner or edits by 5
different users). An answer marked community wiki will no longer earn
reputation from up votes, and users with a rep of only 100 have edit
privileges.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-26 Thread Marc Tompkins
On Sun, May 26, 2013 at 6:17 AM, eryksun eryk...@gmail.com wrote:

 On Sun, May 26, 2013 at 4:34 AM, Steven D'Aprano st...@pearwood.info
 wrote:
 
  So these edits aren't default-deny, but default-accept? Worse and worse.

 It shows who made the edit and when they edited it, which links to the
 revision history. When a question is closed it shows who voted to
 close it. Even retagging shows up in the revision history. Also, since
 it requires a rep of 2000 to edit, generally the system isn't abused.
 Lower-rep users can suggest an edit, but that goes through a review
 process.

 You're notified when someone edits your answer, and you can roll it
 back to a previous version. However, too many edits causes your post
 to become community wiki (I think 10 edits by the owner or edits by 5
 different users). An answer marked community wiki will no longer earn
 reputation from up votes, and users with a rep of only 100 have edit
 privileges.


Once again: I think that the end result (high-quality answers to relevant
questions) justifies a LOT of unpleasantness along the way; probably eight
times ought of ten that I Google a programming question, the best (and
often the first) answer ends up being on StackOverflow.  In general, the
process leads to good quality.  It just, unfortunately, lends itself to
reputation-gaming, and to useless users appearing far more prominent than
they should.  The actual damage that those parasites are able to do to the
ecosystem is limited, however... except that otherwise-motivated users
sometimes get irritated and drop out.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-26 Thread Jim Mooney
On 26 May 2013 15:33, Marc Tompkins marc.tompk...@gmail.com wrote:
 On Sun, May 26, 2013 at 6:17 AM, eryksun eryk...@gmail.com wrote:

StackOverflow may be good but I just had an unpleasant experience
wanting to add New .py file to my Windows context menu. The first
advice I saw was missing a backslash and had me adding the string to
the wrong key. Thankfully, it didn't work and I figured out what was
wrong, so I now have New .py file ;')

Bad programming advice is bad enough, but putting up bad advice to
edit the Windows registry is Really, Really bad.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-26 Thread eryksun
On Sun, May 26, 2013 at 8:25 PM, Jim Mooney cybervigila...@gmail.com wrote:

 StackOverflow may be good but I just had an unpleasant experience
 wanting to add New .py file to my Windows context menu. The first
 advice I saw was missing a backslash and had me adding the string to
 the wrong key. Thankfully, it didn't work and I figured out what was
 wrong, so I now have New .py file ;')

 Bad programming advice is bad enough, but putting up bad advice to
 edit the Windows registry is Really, Really bad.

Did you leave a comment with the correction?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-26 Thread Jim Mooney
 Bad programming advice is bad enough, but putting up bad advice to
 edit the Windows registry is Really, Really bad.

 Did you leave a comment with the correction?

Good point. I wasn't registered on that board but I should go find it.
Not that the mistype in that case could possibly cause a registry
crash. It just didn't work since a backslash in the path to
windows\shellnew was missing, probably due to typing too fast.

-- 
Jim Mooney

There are those who see.
Those who see when they are shown.
And those who do not see.
 -- Leonardo da Vinci
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-24 Thread Marc Tompkins
On Thu, May 23, 2013 at 3:52 PM, Steven D'Aprano st...@pearwood.infowrote:

 On 24/05/13 06:37, Jim Mooney wrote:

 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/205580http://stackoverflow.com/a/10360503/205580
 http://www.wingware.com/doc/**debug/interactive-python-shellhttp://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.


 Beware though, while there are often some very good answers on
 Stackoverflow, there are also very many people who are nowhere near as
 knowledgeable as they think, giving terrible answers, and still having
 large scores. (One particular person comes to mind, I forget his name but
 he has a *very* high score which means lots of people are voting for his
 answers, and yet every time without exception I've seen him reply to
 someone he has been rude, missed the entire point of their question, or
 given them bad advice. Or all three at once.)


I love, love, love StackOverflow (and the whole StackExchange ecosystem),
but it's unfortunately susceptible to being gamed.  Anyone can edit a
question (or an answer), and if the edit is allowed to stand the editor
gets 2 points.  There are millions of questions, so this process can be
repeated ad nauseam.  I used to spend a lot of time on
english.stackexchange.com, and one of the reasons I got fed up with it is
exactly that: unhelpful, opinionated users whose scores were inflated to
make them seem authoritative.  One of them edited several of my answers,
making no change except to turn dashes into Unicode em dashes - and his
score was four times higher than mine, despite hardly having any answers
accepted (due to being a rude, ignorant loudmouth).  I have no problem at
all with true experts having higher scores than mine (especially if they
answer more questions than I, and do it beautifully) but I came to resent
being ranked behind jerks.

The system still _mostly_ works, though, and it sure beats the hell out of
ExpertSexChange or whatever they're calling it these days...
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-24 Thread Steven D'Aprano

On 25/05/13 01:11, Marc Tompkins wrote:


I love, love, love StackOverflow (and the whole StackExchange ecosystem),
but it's unfortunately susceptible to being gamed.  Anyone can edit a
question (or an answer), and if the edit is allowed to stand the editor
gets 2 points.



You can edit *other* people's questions and answers??!??!??

What. The. Hell.



--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-24 Thread Robert Sjoblom
On 25 May 2013 04:19, Steven D'Aprano st...@pearwood.info wrote:
 You can edit *other* people's questions and answers??!??!??

 What. The. Hell.

Yes; I think that the idea is that it allows people to fix spelling
errors and/or reference mistakes, or maybe add things to clarify
something that the answer glossed over to begin with. I'm not entirely
sure how it works other than that you can edit answers and it's then
moderated by someone -- maybe the person who initially wrote the
answer? Or maybe you get moderator rights when reach a certain score.
--
best regards,
Robert S.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-24 Thread eryksun
On Fri, May 24, 2013 at 10:19 PM, Steven D'Aprano st...@pearwood.info wrote:

 You can edit *other* people's questions and answers??!??!??

 What. The. Hell.

This should be done sparingly for answers. But it's very common for
questions since inexperienced users almost always get the markdown
wrong.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-23 Thread eryksun
On Wed, May 22, 2013 at 8:56 PM, Jim Mooney cybervigila...@gmail.com wrote:
 On 22 May 2013 15:05, eryksun eryk...@gmail.com wrote:
 On Wed, May 22, 2013 at 4:30 PM, Jim Mooney cybervigila...@gmail.com wrote:

 Figured it out. Ctrl-C only works in the Windows Command window, not
 in an editor.

 Which IDE?

 Wing. But not being able to abort out of a Windows program is a
 feature. You don't want to lose seven hours of spreadsheet work
 because you forgot and hit ctrl-C. (I just hit Ctrl-C. Nothing, which
 is as it should be ;')

 Well, it's good to be reminded that an editor does funny stuff as
 opposed to command line.

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.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-23 Thread Jerry Hill
On Wed, May 22, 2013 at 9:25 PM, Dave Angel da...@davea.name wrote:

 On 05/22/2013 04:11 PM, Jerry Hill wrote:

 The KeyboardInterrupt ​exception is raised when someone presses Ctrl-C.
  If
 you catch it, and ignore it (which is what your code above is doing), then
 pressing Ctrl-C doesn't do anything.  If you just take out the try/except,
 then you can hit Ctrl-C and interrupt your program as normal.


 What do you mean doesn't do anything ?  It certainly terminates the
 loop, which was the intent.  Provided of course that something else isn't
 trapping the Ctrl-C first.


​You're quite right.  I mis-read the original code as having the try/except
inside the loop.  ​The way Jim wrote it was correct.

-- 
Jerry
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-23 Thread Jim Mooney
 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
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-23 Thread Steven D'Aprano

On 24/05/13 06:37, Jim Mooney wrote:

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.


Beware though, while there are often some very good answers on Stackoverflow, 
there are also very many people who are nowhere near as knowledgeable as they 
think, giving terrible answers, and still having large scores. (One particular 
person comes to mind, I forget his name but he has a *very* high score which 
means lots of people are voting for his answers, and yet every time without 
exception I've seen him reply to someone he has been rude, missed the entire 
point of their question, or given them bad advice. Or all three at once.)

Personally, I think Stackoverflow is a great resource for experienced Python 
programmers who can separate the wheat from the chaff, but only a moderately 
okay resource for beginners :-)




--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] keyboard interrupt

2013-05-22 Thread Jim Mooney
I made a simple ear frequency-tester, but I don't want it to go on
forever, so I tried stopping it when I  pressed a key, as below, but
that doesn't work. I did check out keyboard interrupts but they seem
unnecessarily complex just to stop a program. I'm not passing keys. Is
there something simple I'm missing?

import winsound

try:
for freq in range(100,32000,100):
winsound.Beep(freq, 1000)
except KeyboardInterrupt:
pass

-- 
Jim Mooney
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-22 Thread Marc Tompkins
On Wed, May 22, 2013 at 12:47 PM, Jim Mooney cybervigila...@gmail.comwrote:

 I made a simple ear frequency-tester, but I don't want it to go on
 forever, so I tried stopping it when I  pressed a key, as below, but
 that doesn't work. I did check out keyboard interrupts but they seem
 unnecessarily complex just to stop a program. I'm not passing keys. Is
 there something simple I'm missing?

 import winsound

 try:
 for freq in range(100,32000,100):
 winsound.Beep(freq, 1000)
 except KeyboardInterrupt:
 pass


I've not used it myself, but I believe the KeyboadInterrupt is only
generated by one _specific_ keypress.  You mentioned that you pressed a key
- did you try Control-C?

http://effbot.org/zone/stupid-exceptions-keyboardinterrupt.htm
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-22 Thread Jerry Hill
On Wed, May 22, 2013 at 3:47 PM, Jim Mooney cybervigila...@gmail.comwrote:

 I made a simple ear frequency-tester, but I don't want it to go on
 forever, so I tried stopping it when I  pressed a key, as below, but
 that doesn't work. I did check out keyboard interrupts but they seem
 unnecessarily complex just to stop a program. I'm not passing keys. Is
 there something simple I'm missing?

 import winsound

 try:
 for freq in range(100,32000,100):
 winsound.Beep(freq, 1000)
 except KeyboardInterrupt:
 pass


The KeyboardInterrupt ​exception is raised when someone presses Ctrl-C.  If
you catch it, and ignore it (which is what your code above is doing), then
pressing Ctrl-C doesn't do anything.  If you just take out the try/except,
then you can hit Ctrl-C and interrupt your program as normal.

-- 
Jerry
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-22 Thread Jim Mooney
 I've not used it myself, but I believe the KeyboadInterrupt is only
 generated by one _specific_ keypress.  You mentioned that you pressed a key
 - did you try Control-C?

Actually, I did, using Win 7 - and I put exit() in place of pass. I
tried ctrl-c, ctrl-x, esc, and del. Windows doesn't seem to respond to
anything. The prog just goes to the end

Jim
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-22 Thread Jim Mooney
On 22 May 2013 13:24, Jim Mooney cybervigila...@gmail.com wrote:
 I've not used it myself, but I believe the KeyboadInterrupt is only
 generated by one _specific_ keypress.  You mentioned that you pressed a key
 - did you try Control-C?

 Actually, I did, using Win 7 - and I put exit() in place of pass. I
 tried ctrl-c, ctrl-x, esc, and del. Windows doesn't seem to respond to
 anything. The prog just goes to the end

 Jim

Figured it out. Ctrl-C only works in the Windows Command window, not
in an editor.

Jim



-- 
Jim Mooney

When I got to high school I realized my name would always present
problems. --Dick Hertz
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-22 Thread Marc Tompkins
On Wed, May 22, 2013 at 1:30 PM, Jim Mooney cybervigila...@gmail.comwrote:

 On 22 May 2013 13:24, Jim Mooney cybervigila...@gmail.com wrote:
  I've not used it myself, but I believe the KeyboadInterrupt is only
  generated by one _specific_ keypress.  You mentioned that you pressed a
 key
  - did you try Control-C?
 
  Actually, I did, using Win 7 - and I put exit() in place of pass. I
  tried ctrl-c, ctrl-x, esc, and del. Windows doesn't seem to respond to
  anything. The prog just goes to the end
 
  Jim

 Figured it out. Ctrl-C only works in the Windows Command window, not
 in an editor.


That makes a lot of sense.  And should be added to the list of responses
_next_ time somebody asks Why shouldn't I run production code in IDLE?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-22 Thread eryksun
On Wed, May 22, 2013 at 4:30 PM, Jim Mooney cybervigila...@gmail.com wrote:

 Figured it out. Ctrl-C only works in the Windows Command window, not
 in an editor.

Which IDE?

In IDLE, your code runs in the main thread of a subprocess (unless
IDLE is started with the -n option). A second thread (SockThread) is
started to communicate with PyShell over a socket. When you press
ctrl-c, PyShell executes an interprocess call to
interrupt_the_server(), which simply executes thread.interrupt_main()
-- i.e. interrupt the main thread with a KeyboardInterrupt:

 import thread
 thread.interrupt_main()
Traceback (most recent call last):
  File stdin, line 1, in module
KeyboardInterrupt

Almost certainly your IDE supports interrupting the execution of code.
You just need to configure the key binding. The default binding for
ctrl-c on Windows is to copy the selection to the clipboard.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-22 Thread Jim Mooney
On 22 May 2013 15:05, eryksun eryk...@gmail.com wrote:
 On Wed, May 22, 2013 at 4:30 PM, Jim Mooney cybervigila...@gmail.com wrote:

 Figured it out. Ctrl-C only works in the Windows Command window, not
 in an editor.

 Which IDE?

Wing. But not being able to abort out of a Windows program is a
feature. You don't want to lose seven hours of spreadsheet work
because you forgot and hit ctrl-C. (I just hit Ctrl-C. Nothing, which
is as it should be ;')

Well, it's good to be reminded that an editor does funny stuff as
opposed to command line.

Jim
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-22 Thread Dave Angel

On 05/22/2013 04:11 PM, Jerry Hill wrote:

On Wed, May 22, 2013 at 3:47 PM, Jim Mooney cybervigila...@gmail.comwrote:


I made a simple ear frequency-tester, but I don't want it to go on
forever, so I tried stopping it when I  pressed a key, as below, but
that doesn't work. I did check out keyboard interrupts but they seem
unnecessarily complex just to stop a program. I'm not passing keys. Is
there something simple I'm missing?

import winsound

try:
 for freq in range(100,32000,100):
 winsound.Beep(freq, 1000)
except KeyboardInterrupt:
 pass



The KeyboardInterrupt ​exception is raised when someone presses Ctrl-C.  If
you catch it, and ignore it (which is what your code above is doing), then
pressing Ctrl-C doesn't do anything.  If you just take out the try/except,
then you can hit Ctrl-C and interrupt your program as normal.



What do you mean doesn't do anything ?  It certainly terminates the 
loop, which was the intent.  Provided of course that something else 
isn't trapping the Ctrl-C first.







--
DaveA
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-22 Thread Jim Mooney
 What do you mean doesn't do anything ?  It certainly terminates the loop,
 which was the intent.  Provided of course that something else isn't trapping
 the Ctrl-C first.

It doesn't in Windows proper, using Wing 101. It does exit in the
Windows command console. For some reason I forgot ctrl-C is Copy in
windows. I tried Ctrl-X but I was again confusing the old DOS abort
with Windows Cut. I've been enslaved by the GUI ;')

I'm using Wing 101, which doesn't have a feature set for altering that
behavior. It's probably in the professional version. If I scrape up
spare cash I may go for PyCharm or Wing Pro, but I don't need them on
the low end of the learning curve. I'd just waste time fooling with
them.

The program does exit in Idle, although Idle throws up a Tk screen
asking if you want to abort the program, so it's not a clean exit.

Jim
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] keyboard interrupt

2013-05-22 Thread Dave Angel

On 05/22/2013 09:46 PM, Jim Mooney wrote:

What do you mean doesn't do anything ?  It certainly terminates the loop,
which was the intent.  Provided of course that something else isn't trapping
the Ctrl-C first.


It doesn't in Windows proper, using Wing 101.


Then Wing is changing the behavior, trapping the Ctrl-C.  Not sure why 
you would call Wing the proper Windows.



It does exit in the
Windows command console.


Of course.


For some reason I forgot ctrl-C is Copy in
windows.


Only to programs that have a GUI event loop which happens to trap the 
event.  That's common in Windows, and is required by the CUA standard 
(apparently defunct), but it's not the default behavior of a Windows 
executable.



I tried Ctrl-X but I was again confusing the old DOS abort
with Windows Cut. I've been enslaved by the GUI ;')

I'm using Wing 101, which doesn't have a feature set for altering that
behavior. It's probably in the professional version. If I scrape up
spare cash I may go for PyCharm or Wing Pro, but I don't need them on
the low end of the learning curve. I'd just waste time fooling with
them.

The program does exit in Idle, although Idle throws up a Tk screen
asking if you want to abort the program, so it's not a clean exit.

Jim





--
DaveA
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor