[issue43457] Include simple file loading and saving functions in JSON standard library.

2021-03-09 Thread Inada Naoki


Inada Naoki  added the comment:

I created a new vote for naming.
https://discuss.python.org/t/vote-new-function-for-reading-json-from-path/7603

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43457] Include simple file loading and saving functions in JSON standard library.

2021-03-09 Thread Inada Naoki


Inada Naoki  added the comment:

This idea is discussed several times. Last discussion thread is:
https://mail.python.org/archives/list/python-id...@python.org/thread/YHO575YY4FQC3GBDF4SKOWIEAUSY3OQX/#YHO575YY4FQC3GBDF4SKOWIEAUSY3OQX

--
nosy: +methane

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43457] Include simple file loading and saving functions in JSON standard library.

2021-03-09 Thread nervecenter


New submission from nervecenter :

Python has a "batteries included" approach to standard library construction. To 
that end, commonly used procedures are often included as functions; adding 
sugar to the language is often exchanged for adding sugar to libraries.

One of these common procedures in small-scale scripting tasks is loading a JSON 
file as simple data structures and saving simple data structures as a JSON 
file. This is normally handled using context managers, json.load(), and 
json.dump(). This is a bit cluttered and, I'd argue, not quite as Pythonic as 
the philosophy demands. I have a small file containing this code:

import json

def load_file(filename, *args, **kwargs):
with open(filename, "r") as fp:
data = json.load(fp, *args, **kwargs)
return data

def save_file(data, filename, *args, **kwargs):
with open(filename, "w") as fp:
json.dump(data, fp, *args, **kwargs)

I'd say, toss these two functions into the json module. Those two functions 
contain the clutter. For all other users, loading and saving JSON files become 
one-line function calls. This is convenient and batteries-included.

--
components: Library (Lib)
messages: 388403
nosy: nervecenter
priority: normal
severity: normal
status: open
title: Include simple file loading and saving functions in JSON standard 
library.
type: enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com