Skip to content

Instantly share code, notes, and snippets.

@tamsanh
Created April 12, 2018 00:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamsanh/eb301a8eb06839e31e34d1d0c0d0710a to your computer and use it in GitHub Desktop.
Save tamsanh/eb301a8eb06839e31e34d1d0c0d0710a to your computer and use it in GitHub Desktop.
Gets the name of the calling file.
def get_calling_file_name():
# If this function is embedded in another function, offset the stack appropriately
import inspect
stack_offset = 1
stack = inspect.stack()
calling_file = stack[stack_offset][1]
return calling_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment