Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • But you could be executing the script from another directory, and argv[0] would return the script's path, not yours. Commented Aug 18, 2009 at 21:13
  • 2
    @willehr: The script's path is EXACTLY what the OP requires. Commented Aug 19, 2009 at 0:28
  • 1
    @Daz: (1) syntax error (2) if the absolute path to the script is e.g r"C:\myfiles\fubar.py", the basename is "fubar.py" -- is that what you call "the path of your running script"? Commented Aug 20, 2009 at 13:41