Created
May 7, 2015 23:10
-
-
Save CodyKochmann/263875a53f0615f23b01 to your computer and use it in GitHub Desktop.
Python snippet to get the full path of the script containing the snippet. (good for finding differently positioned workspaces)
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 script_path(include_name=False): | |
# returns the full path of the script containing this snippet | |
# by: Cody Kochmann | |
from os import path | |
full_path = path.realpath(__file__) | |
if include_name: | |
return(full_path) | |
else: | |
full_path = "/".join( full_path.split("/")[0:-1] ) + "/" | |
return(full_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment