Hacker News new | ask | show | jobs
by andrewaylett 3630 days 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.

1 comments

Sure. I'd just like to have a nice set of operations to manipulate dicts that don't mutate and return the result, too.