How to print absolute line number in uncaught exception?
Posted
by
DSblizzard
on Stack Overflow
See other posts from Stack Overflow
or by DSblizzard
Published on 2012-06-08T02:51:50Z
Indexed on
2012/06/08
4:40 UTC
Read the original article
Hit count: 229
When error occured Python prints something like this:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "<stdin>", line 8, in m
File "<stdin>", line 5, in exec_st
File "<stdin>", line 9, in exec_assign
File "<stdin>", line 48, in ref_by_id
IndexError: list index out of range
where 2, ... , 48 are relative line numbers which are not very convenient. How to print absolute line numbers in such error messages?
EDIT: Maybe it's a dumb question, but answer will facilitate development a little. I'm printing text in several files. When done, press shortcut which runs python and copies contents of current file to console. Proposed solution forces to press excess keystrokes (Ctrl+S, Alt+Tab) and create additional files. I hope I have put it clear.
© Stack Overflow or respective owner