2 ms·
One or two try/except is usually fine, but when you are nesting 3+ more try/except with the same error, the code becomes quickly unreadable. Often you would be
by linkerzx 7y ago
One or two try/except is usually fine, but when you are nesting 3+ more try/except with the same error, the code becomes quickly unreadable.
Often you would be better off having a first look at the input to figure out which case you should tackle, decompose the nested try/excepts into separate function or at the very least keep it to two nested levels.