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

Jussi Piitulainen jussi.piitulainen at helsinki.fi
Thu Apr 28 09:24:36 EDT 2016


Adam Funk writes:

> On 2016-04-26, Random832 wrote:
>
>> On Tue, Apr 26, 2016, at 09:30, Adam Funk wrote:
>>> I recently discovered pathlib in the Python 3 standard library, & find
>>> it very useful, but I'm a bit surprised that it doesn't offer things
>>> like is_readable() and is_writable.  Is there a good reason for that?
>>
>> Well, one reason would be EAFP. Just try to open the file and see if it
>> gives you a PermissionError.
>
> I understand that in general, but the tool I'm working on here takes a
> command-line option to specify an output directory, & I'd rather not
> start processing the data (which involves GETting from a REST service,
> processing, and PUTting back modifications to the data) only to crash
> after the first batch because of a user error.

Open an output file first. Crash before reading the first batch.



More information about the Python-list mailing list