Skip to content

Instantly share code, notes, and snippets.

@justb4
Created October 18, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justb4/f45de41856f3610e2869 to your computer and use it in GitHub Desktop.
Save justb4/f45de41856f3610e2869 to your computer and use it in GitHub Desktop.
Python: determine various dirs within executing script
import os,sys
print "CWD: ",os.getcwd()
print "Script: ",sys.argv[0]
print ".EXE: ",os.path.dirname(sys.executable)
print "Script dir: ", os.path.realpath(os.path.dirname(sys.argv[0]))
pathname, scriptname = os.path.split(sys.argv[0])
print "Relative script dir: ",pathname
print "Script dir: ", os.path.abspath(pathname)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment