best way of testing a program exists before using it?

Nick Craig-Wood nick at craig-wood.com
Tue Sep 12 04:30:03 EDT 2006


Tim Golden <tim.golden at viacom-outdoor.co.uk> wrote:
>          if os.path.isfile (filepath):
>            print filepath

You might get a more accurate result using

  os.access(filepath, os.X_OK)

instead of

  os.path.isfile(filepath)

Which checks the file is executable

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list