5 ms·
Here’s how I remember: dumps() takes no file-like argument, thus for dump() and dumps() to be consistent, the object to dump() must come first.
by js2 9y ago
Here’s how I remember: dumps() takes no file-like argument, thus for dump() and dumps() to be consistent, the object to dump() must come first.
- amelius 9y agoThat argument would make as much sense if you replaced first by last.
- js2 9y agoOptional arguments are almost always trailing arguments: dumps(obj) dump(obj, fp) Might be implemented (in a Pythonic way) by the same function: fn(obj, fp=None): ... Another way to think about it is that you're dumping from obj to fp. The thing I always get backwards is C's memcpy(dst, src, len) which I've always thought has its first two arguments in the wrong order.