How to get the name of function in if
statement?
Is there any easy solution?
My case:
if is_wedge(df):
fname = is_wedge.__name__
img_path = Path(main_dir / 'images' / fname / img1.jpeg')
How to get the name of function in if
statement?
Is there any easy solution?
My case:
if is_wedge(df):
fname = is_wedge.__name__
img_path = Path(main_dir / 'images' / fname / img1.jpeg')
Could you use inspect.stack?
import inspect
def iswedge():
stack = inspect.stack() # Get stack info
caller_info = stack[0] # Get caller info
fname = caller_info[3] # Get function name
img_path = Path(main_dir / 'images' / fname / img1.jpeg')