Robert Brewer wrote: > It would be awfully nice (on posix platforms, for my use-case) to find > out whether a file is inaccessible due to permission restrictions, or > due to non-existence. That's easy enough: just check the exception you get when you try opening the file. Don't trust that a negative answer from access() means that you cannot open the file, or that a positive answer means that you can. In short, the implementation of access(2) might lie to you. For example, you might have write access, but writing fails because you are over quota. Or, you are running setuid, and the effective uid is different from the real one. > Can we add an optional "error_if_not_found" arg to > os.access? Make a > new os function with the desired behavior? Either would be fine. Changing the return value would not, since you would have to negate the result. > The next issue, then, is other platforms: is similar functionality > available in OS/2, unix, etc.? On Unix, access(2) can return (in errno) these errors: EACCES, ELOOP, ENAMETOOLONG, ENOENT, ENOTDIR, EROFS, and, optionally, EFAULT, EINVAL, EIO, ENOMEM, ETXTBSY. Regards, Martin
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4