Need Simple Way To Determine If File Is Executable

Tim Roberts timr at probo.com
Sat Dec 16 02:47:30 EST 2006


Tim Daneliuk <tundra at tundraware.com> wrote:
>
>This seems to work, at least approximately:
>
>   os.stat(selected)[ST_MODE] & (S_IXUSR|S_IXGRP|S_IXOTH
>
>It probably does not catch every single instance of something
>that could be considered "executable" because this is a sort
>of fluid thing in Windows (as you point out).

This will tell you that "x.exe" is executable, even if "x.exe" contains
nothing but zeros.

On the other hand, I'm not convinced that any other solution is better.
-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-list mailing list