best way of testing a program exists before using it?
Nick Craig-Wood
nick at craig-wood.com
Tue Sep 12 12:30:03 EDT 2006
Tim Golden <tim.golden at viacom-outdoor.co.uk> 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: http://msdn2.microsoft.com/en-us/library/1w06ktdy.aspx
> 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 craig-wood.com> -- http://www.craig-wood.com/nick
More information about the Python-list
mailing list