I have a function:
# utils.py def hello (name = ' World '): # Find out where I am being called Print (' Hi,% s. You have called it on line #% D from% s. '% (Name, mod, lineno)) # mode The actual usage is set to the previous line of `` `` and `line ' I import that function and it runs anywhere elsewhere
< Code> # other.py (this comment on line # 138) Import from utils Hello Nam From inside Hello ('Johnny') # "Hello", I want to know that this # to ### inspect.currentframe () : Import solution access hello (name = 'world') overlaid frame of "itemprop =" text "): F = inspect.currentframe (). F_back mod = f.f_code.co_filename lineno = f.f_lineno print ('Hi ,% S. You call it% s in line #% D. '% (Name, modern, lineno))
Comments
Post a Comment