What is acceptable in a python try statement
Question: I have a try statement that roughly follows something like this.

    
    
    for result in results['matches']:
        try:
            #runs some functions
        except KeyboardInterrupt:
            leaveopt = raw_input( 'Would you like to exit or skip the current match? [e/s]:' )
            if leaveopt == 'e':
                print '\nExiting...'
            else:
                print '\nSkipping match...'
    

When I run the program I get no errors but when I press ctrl-c it just skips
the current match rather than asking what I would like to do. I'm wondering if
there is only some content that can be ran in the except portion of a try
statement or if there is another problem.


Answer: There's no restriction on what you can do in an `except` as far as I know
(even if there are some things that you may want to avoid here), and this
works for me (python 2.7.3 / linux mint):

    
    
    import time
    
    for x in xrange(5000):
        try:
            print x
            time.sleep(5)
        except KeyboardInterrupt, e:
            leaveopt = raw_input( 
                'Would you like to exit or skip the current match? [e/s]:'
                )
            if leaveopt == 'e':
                print '\nExiting...'
                break
            else:
                print '\nSkipping match...'
                continue
    

The problem is obviously somewhere in the "run some functions" part.

