Created
April 12, 2018 00:11
-
-
Save tamsanh/eb301a8eb06839e31e34d1d0c0d0710a to your computer and use it in GitHub Desktop.
Gets the name of the calling file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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