Skip to content

Instantly share code, notes, and snippets.

@chrisking
Created October 18, 2013 12:57
Show Gist options
  • Select an option

  • Save chrisking/7041150 to your computer and use it in GitHub Desktop.

Select an option

Save chrisking/7041150 to your computer and use it in GitHub Desktop.
def resource_filename(base, path_to_append):
"""
resource_filename takes in any python object, preferably __name__.
It then uses the OS module to determine the full path to the calling
module, then that is joined with any additional path and it
is returned.
"""
base_path = os.path.dirname(os.path.abspath(base))
return os.path.join(base_path, path_to_append)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment