Python vs. Ruby
peter at engcorp.com
Wed Jan 1 23:47:36 CET 2003
Rob Renaud wrote:
> <lot snipped>
> "John Roth" <johnroth at ameritech.net> wrote in message
> > Whether append() returns a *new* object or not is irrelevant to
> > my arguement. The fact that it returns None is the wart.
> > John Roth
> It's consistant, not a wart from my perspective. If an object is
> modified, it is not returned.
> For every part of the (admittedly small) python library I know, that
> is the case. Returning None is a hint that the object is modified.
> So then the question becomes, why don't append(), sort(), reverse()
> return a new list and not modify the original? Are mutable objects
> themselves a wart on the langauge?
I believe the response might be that, in at least the case of sort(),
and probably reverse() as well, creation of a new list would require
twice the memory, at least temporarily, which can be very undesirable.
More information about the Python-list