in python, how to determine on which line exception occured

To save time on debugging, it is always useful to know on which line exception was thrown. In python for this purpose it is useful to always have imported sys module, to refer to its stacktrace,

and the you can do the following:

you get: