Created
November 4, 2014 18:30
-
-
Save mplourde/8fd51d7d9b06f3a85621 to your computer and use it in GitHub Desktop.
get current script directory in python
This file contains hidden or 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
import os | |
import sys | |
def script_dir(): | |
if '__file__' in globals(): | |
return os.path.abspath(os.path.dirname(__file__)) | |
elif sys.argv[0]: | |
return os.path.abspath(os.path.dirname(sys.argv[0])) | |
else: | |
os.path.abspath(os.curdir) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment