check for the presence of an external program on the path

Paul Clinch pclinch at internet-glue.co.uk
Mon Nov 17 21:53:23 CET 2003


Fernando Rodriguez <frr at easyjob.net> wrote in message news:<afehrvgl2p4bcjd2u89epevo0ccdhn6s0b at 4ax.com>...
> Hi,
> 
> How can I find out if an executable is available in the path? 
> 
> TIA

This works on linux:-

import os

ls=os.environ['PATH']

for d in ls.split(':'):
  if 'executable' in os.listdir(d):
    print 'found it!'
    break

Regards, Paul Clinch




More information about the Python-list mailing list