Why does pathlib not have is_readable() & things like that?

Grant Edwards grant.b.edwards at gmail.com
Fri Apr 29 19:53:03 EDT 2016


On 2016-04-29, eryk sun <eryksun at gmail.com> wrote:
> On Fri, Apr 29, 2016 at 6:51 AM, Jussi Piitulainen
><jussi.piitulainen at helsinki.fi> wrote:
>> Adam Funk writes:
>>> On 2016-04-28, Grant Edwards wrote:
>>
>>>> Or just do os.access("directory/where/you/want/to/open/a/file",os.W_OK)
>>>
>>> That's what I'm doing now, but I prefer to give the user the error
>>> message early on.
>>
>> Then do that early on.
>
> Note that on Windows os.access only checks if a file is read-only.
> There's a proposed update to check the file security. The patch needs
> to be updated and needs to be reworked, but it's a low priority. For
> the most part calling os.access isn't recommended.

I'm sure there are probably other ways that it fails also.  That's why
it's almost always simpler and better to just open the file in write
mode and see if it works.

--
Grant





More information about the Python-list mailing list