Where? run directory

Emile van Sebille emile at fenx.com
Mon Sep 29 21:37:10 CEST 2003


"Adrian Smith" asks,
> On a windows system.
> I'm trying to get a Mcmillian created program to be 'independent' but
> the first thing I need to do is find out where the program is being
> run from, not the shortcut but the generated exe. This is where I keep
> all the set-up files that I need to access.
> Currently I have a fixed directory but don?t want to write anything
> into the registry.
> Is there a reg setting though that gives the address of the last run
> program (presumably my program) or something like a working directory
> setting.
> I don?t want to have to search for the program through the directory
> structure as that would be very time consuming.
>

I think you're looking for:

import os
print os.path.dirname(__file__)


HTH,

Emile van Sebille
emile at fenx.com






More information about the Python-list mailing list