[BangPypers] "continue" in "try..except"

Nikunj.Badjatya at emc.com Nikunj.Badjatya at emc.com
Mon Nov 21 11:33:30 CET 2011


Hey Philippe,
Thanks exactly what I wanted.
My main() is calling other scripts written in powershell(.PS1) using subprocess.call().
Will this mechanism work in that case also ? I mean will this resume the execution from the same place where it left off as desired ?

Nikunj

-----Original Message-----
From: bangpypers-bounces+nikunj.badjatya=emc.com at python.org [mailto:bangpypers-bounces+nikunj.badjatya=emc.com at python.org] On Behalf Of Philippe May
Sent: Sunday, November 20, 2011 7:25 PM
To: bangpypers at python.org
Subject: Re: [BangPypers] "continue" in "try..except"

Resuming the execution in an except clause seems unclean and unlikely. What about the context? Where in the stack to resume? This would lead to more problems than anything else.

Here i think we are basically not dealing with exceptions but signals, and this might work as expected:

import signal
def signal_handler(signal_number, frame):
    ret = raw_input('Really abort? (y/n) ')
    if ret == 'y':
        print('Committing Hara Kiri')
        sys.exit(0)

## Install the signal handler:
signal.signal(signal.SIGINT, signal_handler)

Philippe

> From: Navin Kabra <navin.kabra at gmail.com>
>> 
>> On Sun, Nov 20, 2011 at 2:48 PM, <Nikunj.Badjatya at emc.com> wrote:
>> 
>>> Are you 100% certain that this mechanism is not available in Python.?
>>> I think this is very generic usecase of exception handling. !?
>>> 
>> 
>> While I'm not 100% certain that this is not available in Python, I am 100%
>> certain that this is not a "generic usecase of exception handling". Can you
>> give examples in other languages?
>> 
_______________________________________________
BangPypers mailing list
BangPypers at python.org
http://mail.python.org/mailman/listinfo/bangpypers



More information about the BangPypers mailing list