On 17 dic, 19:21, "Roger Upole" <[EMAIL PROTECTED]> wrote: > >> > os.stat(selected)[ST_MODE] & (S_IXUSR|S_IXGRP|S_IXOTH > > >>This will tell you that "x.exe" is executable, even if "x.exe" contains > >> nothing but zeros. > > > Isn't the same with any other recipe, portable or not? Unless the OS > > actually tries to load and examine the file contents, which the OS's > > I'm aware of, don't do. > > On windows, you can use win32file.GetBinaryType to check if a file is actually > a binary executable.
A similar function exists on Linux too. But even if a file has the right file format, if it does not have the execute bit set, won't run. And you could set that bit on a JPG image too - and nothing good would happen, I presume. So one must determine first what means "the file is executable". -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list