3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by _neo_
0

Do not use unconditional except, you stop for example key interrupt.

Check the error code you get without except, say it is TheErrorType then do

try:
    #your stuff with potential for interrupt as little lines as possible
except TheErrorType as e:
    print 'Got error %s in the input, ignoring' % e
else:
    # normal stuff if interrupt did not happen
finally:
    # clean up code common for both cases

Edited by pyTony: n/a

0

Thank you tonyjv and woooee.
I'm using tonyjv's syntax with sys.exc_info() function:

exc_type, exc_value, exc_trbk = sys.exc_info()
    print(exc_type,exc_value)
    ret_str = str(exc_value)
    sock.sendto(ret_str.encode('ascii'),0,addr)
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.