
(I must have missed the 'try' suffix) On Sun, Oct 11, 2020, 1:04 PM Wes Turner <wes.turner@gmail.com> wrote:
Nested exceptions indicated by a 'try' suffix added to the exception expression
How could these (else-if and nested conditional) syntaxes be combined?
On Sun, Oct 11, 2020, 12:46 PM David Mertz <mertz@gnosis.cx> wrote:
I'm not advocating for it (nor against it). But the OP proposes something clear different from the example in current Python.
On Sun, Oct 11, 2020, 12:39 PM Wes Turner
try: f = open('myfile.txt') s = f.readline() i = int(s.strip()) except OSError as err: print("OS error: {0}".format(err)) except ValueError: print("Could not convert data to an integer.") except: print("Unexpected error:", sys.exc_info()[0]) raise ```
I.e.
try: might_raise_OSError() except OSError as err try: might_raise_ValueError() except ValueError try: might_raise_other() except: oh_well()
The proposal is to more concisely catch exceptions raised within the 'except' suites themselves.