Locating Relative Resource Files

Don Garrett garrett at bgb.cc
Wed Sep 12 16:23:42 EDT 2001


  I'm putting together a quick proof of concept/demo on windows. It's
intended to be distributed as a zip file which people expand, click on
the .pyw file, and run. (And yes, I know they need to have python
installed for this). No configuration is allowable.

  However, it has some external files (an external dos application) that
need to be referenced relative to the location of the python program.

  Current working directory is correct, if the python program is
launched from the command line, but not if it's launched (in windows) by
clicking on the file.

  Is there some way to determine the location of the file from which
the currently executing source was loaded? Or the file/directory of
the initial python script?

--
Don Garrett                                   http://www.bgb.cc/garrett/
BGB Consulting                                            garrett at bgb.cc



More information about the Python-list mailing list