How do I find the directory of the running Python script from inside Python [3.3]? I have tried what was suggested at: How can I find script's directory? , but I get "Invalid syntax" and directed to "os" (And I did import os).
The closest I have got to the answer is: sys.argv[0]
, but that still includes the file name, so I cannot use it. Is there any other way?
The part where it says rundir = sys.argv[0]
is where the suggested code will go:
import os, sys
rundir = sys.argv[0]
print("Running from" + rundir)