For example, is there anything that could be added to the following that could provide the line number of the error?
try:
assert False
except Exception, e:
# lineOfError = ?
# print lineOfError
print e
For example, is there anything that could be added to the following that could provide the line number of the error?
try:
assert False
except Exception, e:
# lineOfError = ?
# print lineOfError
print e
You can use the traceback
module:
from sys import exc_info
from traceback import extract_tb
try:
assert False
except Exception as e:
print(extract_tb(exc_info()[2])[0][1])
print(e)