file mode attributes...

Martin v. Löwis loewis at informatik.hu-berlin.de
Tue Sep 17 03:13:03 EDT 2002


"Bjorn Pettersen" <BPettersen at narex.com> writes:

> Thanks. Do you think there would be any interest in adding these
> kinds of utility functions to e.g. the os.path module?

I doubt that. Your implementation is valid only on Windows, on Unix,
you need to determine whether you are interested in user, group, or
other bits, and you also have not only read and write, but also
execute. The current API is as portable and convenient is it can get.

Also, finding out that way that a file is writable does not mean you
can write to it:
- the file might be on a read-only file system (will report EROFS, on
  Unix),
- the Win32 ACL might prevent writing,
- on Unix, you need to get your owner and group id,
- the Unix euid/fsuid might prevent writing, as it might differ from
  your user id,
- the file system might be full.

So the only way to truly find out whether you can read is to attempt
to read or write, and prepare for an exception.

> win32all isn't standard on Windows <wink>? 

No; that's a huge code base, and nobody has proposed to incorporate it
into Python proper.

Regards,
Martin





More information about the Python-list mailing list