Finding startup files

Grant Edwards grante at visi.com
Wed May 11 12:44:19 EDT 2005


On 2005-05-11, hemagician at gmail.com <hemagician at gmail.com> wrote:
> The following script demonstrates a method that should work for you. I
> believe it is entirely cross-platform.
>
> #! /usr/bin/python
>
> import sys
> import os
>
> print os.path.abspath(os.path.dirname(sys.argv[0]))

That will probably work most of the time, but...

 1) you're not gauranteed that argv[0] contains the application
    path/filename.

 2) the directory containing the executable is not where
    configuration files are supposed to be stored under
    Unix/Linux.

-- 
Grant Edwards                   grante             Yow!  hubub, hubub, HUBUB,
                                  at               hubub, hubub, hubub, HUBUB,
                               visi.com            hubub, hubub, hubub.



More information about the Python-list mailing list