Why no isexec, isread, iswrite, etc (was: I must be missing something obvious: os.path.isexecutable?)

David Bolen db3l at fitlinxx.com
Fri Jan 19 00:29:44 EST 2001


grey at despair.rpglink.com (Steve Lamb) writes:

>     then I foudn the above mentioned conversation with the macros from stat
> coming into play.  So I dug into os.path.py, bounced into posixpath.py, and
> see that isdir, isfile and islink use the stat macros.  So why not complete
> the suite of tests possible from the stat macros and have read/write/exec
> tests in there as well?

One possibility is that there's more than one answer to the question
of "isexec" - it's not a single bit, but one that can exist for all of
owner, group and world.  Thus, for example, Perl has both -x and -X to
deal with effective and real uid/gid, but even then the brief writeup
I found via perldoc doesn't get very descriptive of under precisely
what conditions they return true.  (E.g., what if it's only other
executable - is that covered by the "effective uid/gid" of -x?)

I'm sure it wouldn't be too terrible to spec out something that is
well-defined and augment the module.  But it's also not too much
effort to just stat the file (which is going to happen anyway) and
then apply the heuristic that you want in your particular situation.

(Clearly in this case, part of the question is precisely what is the
algorithm used by -x in Perl since you are trying to replicate its
behavior)

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list