#py
filename and line number of Python script
stackoverflow.com›filename-and-line-number-of-python-script
Thanks to mcandre, the answer is:
filename and line number of Python script
stackoverflow.com›filename-and-line-number-of-python-script
Thanks to mcandre, the answer is:
#python3
from inspect import currentframe, getframeinfo
frameinfo = getframeinfo(currentframe())
print(frameinfo.filename, frameinfo.lineno)
Stack Overflow
filename and line number of Python script
How can I get the file name and line number in a Python script?
Exactly the file information we get from an exception traceback. In this case without raising an exception.
Exactly the file information we get from an exception traceback. In this case without raising an exception.