Short Question: I can find the line number when a function called as in mentioned here
Similarly, how can I find column number?
Long Question:
def col():
return something
print("result", col(), col(), col())
should return different numbers from each other, the same numbers whenever this print function is called.
How can I make this?
EDIT:
My workaround right now is as follows:
import inspect
def cid():
f = inspect.currentframe().f_back
caller_id = (f.f_lineno, f.f_lasti)
return caller_id
print((cid(), cid(), cid(), cid(), cid()))
print((cid(), cid(), cid(), cid(), cid()))
print((cid(), cid(), cid(), cid(), cid()))
print((cid(), cid(), cid(), cid(), cid()))
print((cid(),
cid(),
cid(),
cid(),
cid()))
works as expected (for now). This prints:
((8, 30), (8, 36), (8, 42), (8, 48), (8, 54))
((9, 65), (9, 71), (9, 77), (9, 83), (9, 89))
((10, 100), (10, 106), (10, 112), (10, 118), (10, 124))
((11, 135), (11, 141), (11, 147), (11, 153), (11, 159))
((13, 170), (14, 176), (15, 182), (16, 188), (17, 194))
Problem: I don't know what f_lasti brings exactly at a moment.