6 ms·
Your first point is actually something I really like about Python's API design: in general, methods operating on collections either mutate the collection /or/ t
by andrewaylett 10y ago
Your first point is actually something I really like about Python's API design: in general, methods operating on collections either mutate the collection /or/ they return it. So it's clear at the point of use whether you're dealing with the same object or a new one.
This is something that bugs me about the fluent builder pattern in Java -- continuing to return `this` until suddenly you don't any more, and you can't re-use 'intermediate' values because they're actually all the same object.
- eru 10y agoSure. I'd just like to have a nice set of operations to manipulate dicts that don't mutate and return the result, too.