
+1 because the general idea is one of my most commonly used utility functions. There should also be a similar function for writing to a file, e.g. json.dumpf if we stick to this naming scheme. As an alternative, pathlib.Path.read/write_text are pretty cool, maybe we could have .read/write_json? In any case if we add anything like this it would probably make sense to add similar functions for pickle, and maybe other formats if the API is obvious enough. On Fri, Sep 11, 2020 at 10:40 PM The Nomadic Coder <atemysemicolon@gmail.com> wrote:
Hi All,
This is the first time I'm posting to this mailing group, so forgive me if I'm making any mistakes.
So one of the most common ways to load json, is via a file. This is used extensively in data science and the lines. We often write something like :-
with open(filename.json, "r") as f: my_dict = json.load(f)
or my_dict = json.load(open("filename.json", "r"))
Since this is sooooo common, why doesn't python have something like :- json.loadf("filename.json")
Is there an obvious issue by defining this in the cpython? I don't whipping up a PR if it gains traction. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/YHO575... Code of Conduct: http://python.org/psf/codeofconduct/