Re: resume execution after catching with an excepthook?

2012-10-25 Thread andrea crotti
2012/10/25 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: On Wed, 24 Oct 2012 13:51:30 +0100, andrea crotti wrote: So I would like to be able to ask for confirmation when I receive a C-c, and continue if the answer is N/n. I don't think there is any way to do this directly. Without

Re: resume execution after catching with an excepthook?

2012-10-25 Thread Chris Angelico
On Thu, Oct 25, 2012 at 12:15 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I don't believe that there is any way to jump back to the line of code that just failed (and why would you, it will just fail again) There are several reasons to retry something after an exception,

Re: resume execution after catching with an excepthook?

2012-10-25 Thread Hans Mulder
On 24/10/12 14:51:30, andrea crotti wrote: So I would like to be able to ask for confirmation when I receive a C-c, and continue if the answer is N/n. I'm already using an exception handler set with sys.excepthook, but I can't make it work with the confirm_exit, because it's going to quit in

Re: resume execution after catching with an excepthook?

2012-10-25 Thread Steven D'Aprano
On Fri, 26 Oct 2012 01:51:43 +1100, Chris Angelico wrote: On Thu, Oct 25, 2012 at 12:15 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I don't believe that there is any way to jump back to the line of code that just failed (and why would you, it will just fail again)

Re: resume execution after catching with an excepthook?

2012-10-25 Thread Chris Angelico
On Fri, Oct 26, 2012 at 2:31 AM, Hans Mulder han...@xs4all.nl wrote: This seems to work; I'm not sure how robust it is: import signal def handler(signum, frame): while True: q = raw_input(This will quit the program, are you sure? [y/N]) if q[:1] in yY:

RE: resume execution after catching with an excepthook?

2012-10-25 Thread Prasad, Ramit
andrea crotti wrote: 2012/10/25 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: On Wed, 24 Oct 2012 13:51:30 +0100, andrea crotti wrote: [snip] Without a try...except block, execution will cease after an exception is caught, even when using sys.excepthook. I don't believe that there

resume execution after catching with an excepthook?

2012-10-24 Thread andrea crotti
So I would like to be able to ask for confirmation when I receive a C-c, and continue if the answer is N/n. I'm already using an exception handler set with sys.excepthook, but I can't make it work with the confirm_exit, because it's going to quit in any case.. A possible solution would be to do

Re: resume execution after catching with an excepthook?

2012-10-24 Thread Steven D'Aprano
On Wed, 24 Oct 2012 13:51:30 +0100, andrea crotti wrote: So I would like to be able to ask for confirmation when I receive a C-c, and continue if the answer is N/n. I don't think there is any way to do this directly. Without a try...except block, execution will cease after an exception is