best way of testing a program exists before using it?

Tim Golden tim.golden at viacom-outdoor.co.uk
Tue Sep 12 04:40:06 EDT 2006


[Nick Craig-Wood]

| 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

Sadly, not under Win32, hence the shenanigans with
the PATHEXT variable :)

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________



More information about the Python-list mailing list