getting source code line of error?
Ulli Horlacher
framstag at rus.uni-stuttgart.de
Sat Nov 20 14:15:32 EST 2021
Stefan Ram <ram at zedat.fu-berlin.de> wrote:
> ram at zedat.fu-berlin.de (Stefan Ram) writes:
> >except Exception as inst:
> > print( traceback.format_exc() )
>
> More to the point of getting the line number:
As I wrote in my initial posting:
I already have the line number. I am looking for the source code line!
So far I use:
m = re.search(r'\n\s*(.+)\n.*\n$',traceback.format_exc())
if m: print('%s %s' % (prefix,m.group(1)))
--
Ullrich Horlacher Server und Virtualisierung
Rechenzentrum TIK
Universitaet Stuttgart E-Mail: horlacher at tik.uni-stuttgart.de
Allmandring 30a Tel: ++49-711-68565868
70569 Stuttgart (Germany) WWW: http://www.tik.uni-stuttgart.de/
More information about the Python-list
mailing list