I have a code similar to this:
try:
if x:
statement1
statement2
statement3
elif y:
statement4
statement5
statement6
else:
raise
except:
statement7
Here, I am sure that the exception occurs in If x: block, but I would like to know in which statement of If x: block the exception occurs. Is there a way to get the line number where the exception occurs?
Regards,
what about this:
this is the straightforward workaround but I suggest to use a debugger
or even better, use the sys module 😀