Python vs. Ruby

Stuart D. Gathman stuart at bmsi.com
Wed Jan 8 21:33:07 CET 2003


On Thu, 02 Jan 2003 11:13:10 -0500, Nicodemus wrote:

> Brian Quinlan wrote:

> "The sort() and reverse() methods modify the list in place for economy
> of space when sorting or reversing a large list. To remind you that they
> operate by side effect, they don't return the sorted or reversed list."
> 
> I myself don't care much about chaining method calls, since the gains
> are relatively small compared to the confusion (as explained by Brian)
> that such a change would cause. I don't think adding "reversed()" and a
> "sorted()" methods to lists would be a good idea (like suggested in
> other emails in this thread), since it would cause even more confusion.

Smalltalk has a special syntax for chaining methods get the best of both
worlds.  The smalltalk operator ';' is already taken in Python, but let
me make a quick stab at a Python substitute:

  aList.sort();.reverse()	# aList.sort(); aList.reverse()

A statement cannot begin with '.', so ';.' means to invoke another method
on the same object.

-- 
	      Stuart D. Gathman <stuart at bmsi.com>
Business Management Systems Inc.  Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flamis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.




More information about the Python-list mailing list