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

David Bolen db3l at fitlinxx.com
Mon Jan 22 15:37:54 EST 2001


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

>     Then while looking for an answer for another person's question I ran
> across os.access().
> 
>     Oddly enough it works just fine even though on this install (1.5.2,
> Debian) I cannot appear to find where access is defined in os.py or
> posixpath.py.  

The core os functions are actually built-in to Python, via a built-in
module appropriate to the OS under which Python is running.  You can
see the os.py module import all the names from any of posix, nt, dos,
os2, or mac depending on the builtin module.

>     Soooooo, right back were we started.  Wouldn't it be easier to have these
> with their counterparts in os.path at the very least for consistency's sake?
> Glad I found them, though.  Also, does anyone know where they are in the
> libraries so I may see the code?

I see os.path really as just a subset of the OS module that affects
path manipulation (in that respect, I suppose some of the is*
functions perhaps should be in the main os module), but I don't know
how the line has been drawn in the past.  It may have also depended on
what functions could be easily externalized in Python code rather than
being part of the core builtin modules, I'm not sure.

But in general, I think of os and os.path as a combined unit (in fact
you'll note that os will automatically import os.path, so you can use
both modules by just importing os - perhaps there was a split in the
modules in the past).

You can find the code for the primary os module functions in the
appropriate piece of the Python source code - the POSIX, NT, Windows
and OS/2 version are in modules/posixmodule.c.  I'm not sure where the
MAC variation is kept.

--
-- 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