Retrieving the full path of Unix apps

Lorin Hochstein me at nospam.com
Tue Oct 5 16:35:38 EDT 2004


Grant Edwards wrote:
> On 2004-10-05, Lorin Hochstein <me at nospam.com> wrote:
>
> 
> Do you care _which_ path you end up with in the case where
> there are multiple ones that end in the filename of interest?
> 
> Are you assuming that the program is in one of the directories
> listed in the PATH environment variable?
> 

Sorry, I should've been more clear. I am assuming the program is in one 
of the directories listed in the PATH environment variable. I want the 
same one that 'which' will return: the one that would get invoked if 
someone just typed in the name of the program at the command-line.

> 
> You could grab the value of the environment variable PATH, and
> search those directories for the file in question.  That's
> pretty much what the 'which' command does.
> 

That does seem more elegant than relying on 'which'.

Thanks,


Lorin




More information about the Python-list mailing list