Get Path of current Script
Ulrich Eckhardt
ulrich.eckhardt at dominolaser.com
Mon Mar 14 09:05:31 EDT 2011
Alexander Schatten wrote:
> Thanks for the comments so far. This sounds to be more complicated in
> detail than I expected. I wonder how all the other Python programs and
> scripts are doing that...
Well, it's not like that's impossible to find out, the source is out
there! :)
Anyhow, you basically have two variants AFAIK:
1. Unix variant
Here, you have the program in the bin directory (e.g. /usr/bin/foo) and the
required data files in a library directory (e.g. /usr/lib/foo/data). The
location of the latter is fixed when the program is installed, i.e. the
path is coded as a placeholder in the source and then replaced according to
the installation-path.
2. Windows variant
Here, the program is installed completely in a folder (e.g. C:\Program
Files\foo) where both the program itself and any other data files are
installed. The special folder (e.g. C:\Program Files) where programs are
stored can be retrieved from the OS, the program-specific path that follows
is usually hard-coded.
Uli
--
Domino Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
More information about the Python-list
mailing list