0

I want to read the path of the directory from where I call the python script. I do not want to know where the script itself is located, but from where I click on a link to it. I tried os.getcwd but that only gives me the directory from where it is saved.

ari
  • 1,122
  • 1
  • 9
  • 15
  • what do you mean, link? as in a web-based link to a script on a web server? – Marc B Jul 28 '15 at 21:10
  • So, if you're running it from a shortcut or batch file, you want the location of that shortcut link or batch file? That information isn't provided automatically, so if you want to pass it along you'll have to do so yourself (with a command line argument or something). – TigerhawkT3 Jul 28 '15 at 21:11
  • No I mean like a link I can create in a random folder on my computer (I hope the word link is the correct expresson for this.). – ari Jul 28 '15 at 21:11
  • How exactly can I pass this along? I'm new to this. – ari Jul 28 '15 at 21:14
  • Are you attempting to see it through a webserver? It'll be in your www or cgi structure – FirebladeDan Jul 28 '15 at 21:14
  • No, I only want to see it on my computer. I want to create a keyboard shortcut (using Fastkeys) that calls the program which is supposed to open all files in the directory where I used the shortcut. So the program needs to know from where it is called...Is this impossible to do? – ari Jul 28 '15 at 21:17
  • http://stackoverflow.com/questions/60904/how-can-i-open-a-cmd-window-in-a-specific-location So you can use powerToy to go directly to the script location and run it – FirebladeDan Jul 28 '15 at 21:17
  • No, it's all just on my own PC... – ari Jul 28 '15 at 21:19
  • This looks interesting. How can I copy the path in the cmd and put it in the python script I am calling? Ctrl C does not work in the cmd line... – ari Jul 28 '15 at 21:28
  • 1
    getcwd should work, unless you are running in a strange environment. Are you on Windows, or Linux? In the latter case, are you using virtualenv? Note that this last case you'll get the wd of the environment, not from the main file system. – jcoppens Jul 28 '15 at 22:49

0 Answers0