On 04/05/14 13:54, Dave Angel wrote:
Alan Gauld <alan.ga...@btinternet.com> Wrote in message:

I assumed (never assume!) that it returned a reference to the original.
I really, really, hate the way Python handles this :-(

It's not clear to me what you would change. Would you only provide
  methods (like sort) that mangle their object?

No, I'd not provide methods that work on the object and return None.
I much prefer the Smalltalk model where if all else fails you return self. Since Python has objects everywhere they could easily have adopted that model, it is so much more consistent. And it also allows method chaining... But just the consistency of always getting a useful
object (I don't mean None!)  back makes a big difference to programming.

It does mean you need to make copy semantics obvious in the naming
but that's not too onerous. So sorted() would become sortedCopy() or some such.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to