Running a file, with a relative filename

Nathan Clegg nathan at islanddata.com
Mon May 17 12:47:02 EDT 1999


On 15-May-99 Fredrik Lundh wrote:
> Nathan Clegg <nathan at islanddata.com> wrote:
>> A more bulletproof method would append
>> 'yyy' in some way to the current sys.path[0]
>> entry.
> 
> you mean sys.argv[0], don't you?  sys.path[0] tends
> to be blank most of the time, at least on my boxes.

No...sys.path[0] is the location of the script being run, so that a
script's "personal" modules will always come before global modules in the
search path.  sys.path[0] is only empty when you are executing a script in
the current directory (i.e. './script.py' or 'python ./script.py').

----------------------------------
Nathan Clegg
 nathan at islanddata.com






More information about the Python-list mailing list