3 ms·
_The csv version returns an iterator over a closed file_ That's why method/function naming is critical and underestimated. Without having worked with python to
by bassman9000 6y ago
_The csv version returns an iterator over a closed file_
That's why method/function naming is critical and underestimated. Without having worked with python too much:
_json.load()_ is a load: implies the action is done on return. I understand there's nothing to do after it, other than use the return value.
_csv.reader()_ clearly returns an object that it's going to be used to traverse the underlying, so the underlying must remain open. Implies a stateful operation to me.
Besides, examples are clear:
https://docs.python.org/3.8/library/csv.html#examples https://docs.python.org/3.8/library/csv.html#examples
Classical problem of wanting to use The Perfect Abstraction.