Linux application deployment

Grant Edwards grante at
Sun Sep 5 18:22:02 CEST 2004

On 2004-09-05, Jarek Zgoda <jzgoda at> wrote:
> Robert M. Emmons <RobMEmmons at> pisze:
>> One thing I've always wonders was -- Is there a way for a python module 
>> to tell where it's file is located???  If you could do this it might 
>> also be possible to have a python script reset sys.path based on it's 
>> own location.
> import sys, os
> me = os.path.abspath(sys.argv[0])

That's only mostly reliable.  Nothing in Linux/Unix actually requires that
argv[0] be the program's path.  It is the convention to pass that as
argv[0], but there may be corner cases where it doesn't work.

Grant Edwards                   grante             Yow!  I had pancake makeup
                                  at               for brunch!

More information about the Python-list mailing list