2017-03-27 17:04 GMT+02:00 Steven D'Aprano <st...@pearwood.info>:
> Of course pathlib can already read JSON, or for that matter ReST text
> or JPG binary files. It can read anything as text or bytes, including
> JSON:
>
> some_path.write_text(json.dumps(obj))
> json.loads(some_path.read_text())

Note: You should specify the encoding:

some_path.write_text(json.dumps(obj), encoding='utf8')
json.loads(some_path.read_text(encoding='utf8'))


> I don't think it should be pathlib's responsibility to deal with the
> file format (besides text).

Right.

Victor
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to