best way of testing a program exists before using it?

Nick Craig-Wood nick at
Tue Sep 12 18:30:03 CEST 2006

Tim Golden <tim.golden at> wrote:
>  Also, I just looked at the implementation in posixmodule.c,
>  and at the msdn article on its use, and at a thread in python-dev
>  a year or so ago. The last -- where someone was proposing more
>  specifics if the call fails -- didn't really go anywhere, and is
>  full of people (GvR and others) saying: don't use os.access unless...
>  The msdn article:
>  doesn't even seem to suggest that checking for executableness is a
>  possibility, and I think that the posixmodule.c code is simply
>  swallowing any non-OK return value and saying: No. (The msdn page
>  suggests that invalid parameters will return EINVAL).
>  All that said, I think the only thing would be to add a line to
>  the docs saying sthg like: This will always return False for X_OK under
>  Win32. I'm happy to submit the patch, but is it worth it?

Wouldn't returning X_OK as true if the file exists be more sensible?
Ie the file might be executable, you'll have to try it, rather than,
no this file is definitely not executable...

Nick Craig-Wood <nick at> --

More information about the Python-list mailing list