0

I've got a question. How can a program get its own location? For example, I've got a script ("script.py") on a path ("C:\Programs\script.py"). I want a function, which gives me the path. Like the following:

scriptdic() ==> "C:/programs/"

Thanks for coming answers.

1 Answers1

2

this should do the trick. . .

import os.path
import sys

os.path.dirname(sys.argv[0])
mgilson
  • 300,191
  • 65
  • 633
  • 696