[Python-ideas] Add pathlib.Path.write_json and pathlib.Path.read_json

Donald Stufft donald at stufft.io
Mon Mar 27 10:42:39 EDT 2017


> On Mar 27, 2017, at 10:36 AM, Paul Moore <p.f.moore at gmail.com> wrote:
> 
> On 27 March 2017 at 15:33, Donald Stufft <donald at stufft.io <mailto:donald at stufft.io>> wrote:
>> What do you think about adding methods pathlib.Path.write_json and
>> pathlib.Path.read_json , similar to write_text, write_bytes, read_text,
>> read_bytes?
>> 
>> 
>> 
>> -1, I also think that write_* and read_* were mistakes to begin with.
> 
> Text is (much) more general-use than JSON.


Sure. I also think touch() and all the others are the same :) I think they’re just an unfortunate detritus of a time before PathLike and that it’s super weird to have some operations you do to a file path (compared to things you do to generate, modify, or resolve a path) be hung off of the Path object and every other be an independent thing that takes it as an input. I’d find it equally weird if dictionary objects supported a print() or a .json() method.

—
Donald Stufft



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170327/bb69b94b/attachment-0001.html>


More information about the Python-ideas mailing list