On Fri, Sep 13, 2013 at 4:13 AM, Markus Rother <pyt...@markusrother.de> wrote: > On 12.09.2013 01:27, Chris Angelico wrote: >> On Thu, Sep 12, 2013 at 6:41 AM, Markus Rother <pyt...@markusrother.de> >> wrote: >>> 3. The default return value of methods is None instead of self. >>> If it was self, it would be possible to chain method calls (which >>> is called a cascade in smalltalk). >> >> That's a policy decision: a method (or function) will *EITHER* return >> a value, *OR* mutate its primary argument (in the case of a method, >> that's self). > > You are stating: "All getters must be free of side effects". > That is not the case. Furthermore, the demand for getters with hidden > side effects is the reasoning behind properties.
This isn't a language feature here, just a stdlib policy. It's more akin to Ruby's habit of adorning the mutating methods with an exclamation mark - it's a way of stopping you from accidentally doing what you didn't mean to do. There's a sharp distinction between list.sort(), which mutates in place and returns None, and sorted(), which doesn't touch its argument and returns a new list. ChrisA -- https://mail.python.org/mailman/listinfo/python-list