Skip to content

Instantly share code, notes, and snippets.

@mplourde
Created November 4, 2014 18:30
Show Gist options
  • Save mplourde/8fd51d7d9b06f3a85621 to your computer and use it in GitHub Desktop.
Save mplourde/8fd51d7d9b06f3a85621 to your computer and use it in GitHub Desktop.
get current script directory in python
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