def PrintFrame():
    callerframerecord = inspect.stack()[1]
frame = callerframerecord[0]
info = inspect.getframeinfo(frame)
print(info.filename)
print(info.function)
print(info.lineno)

def Main():
    PrintFrame()
Main()
How to determine file, function and line number?