Inspect - Line Number
Riassunto:
current line number in Python source code Documentazione
Codice
import inspect
current_frame = inspect.currentframe()
call_frame = inspect.getouterframes(current_frame, 2)
print('caller frame:', call_frame[1][2])
>>> 51