
Nov. 28, 2021
7:13 a.m.
Chris Angelico writes:
The policy of not returning self is, from my understanding, to clarify which methods return a new thing and which mutate the existing one. It makes this sort of distinction very obvious:
That seems likely.
If list.sort() returned self after mutation, the second one would appear to work, but would leave the original list in a different order.
Which is what I would expect for a *sort* *method*. But I guess others might not think about it and be unpleasantly surprised.