Re: What about an EXPLICIT naming scheme for built-ins?

From: Andrew MacIntyre (andymac_at_bullseye.apana.org.au)
Date: 09/04/04


Date: Sat, 4 Sep 2004 09:15:56 +1000 (EST)
To: python-list@python.org

On Fri, 3 Sep 2004, Marco Aschwanden wrote:

> sort() works in-place.
> reverse() works in-place.
>
> The past tense of sort() indicates that a copy of the sequence is returned.
> The past tense of reverse() indicates that an iterator over the original
> sequence is returned.

This may be a language nuance, but neither "sort" nor "reverse" are past
tense - they are verbs, which imply an action. In this sense they are
totally appropriate as method names for inplace operations, as they
signify actions applied to the object.

"sorted" and "reversed" have past tense. As I recall, there was some
discussion on the python-dev mailing list on names for these methods for
the non-inplace versions of these operations; these were the outcome.

There is no chance before Python 3000 that sort() and reverse() will
change name - there is too much code to break.

-------------------------------------------------------------------------
Andrew I MacIntyre "These thoughts are mine alone..."
E-mail: andymac@bullseye.apana.org.au (pref) | Snail: PO Box 370
        andymac@pcug.org.au (alt) | Belconnen ACT 2616
Web: http://www.andymac.org/ | Australia



Relevant Pages

  • What about an EXPLICIT naming scheme for built-ins?
    ... can be used in expressions, as it returns a copy of the sequence, sorted. ... reverse() works in-place. ... The past tense of sort() indicates that a copy of the sequence is returned. ...
    (comp.lang.python)
  • sorting list
    ... Is it possible to sort a list from top to bottom (reverse the sequence) in ...
    (microsoft.public.word.newusers)
  • Re: Equivalents of Rubys "!" methods?
    ... reversedon the same list returns an iterator? ... the algorithm required to sort a sequence is something entirely different from the algorithm required to loop over a sequence in reverse. ...
    (comp.lang.python)
  • Re: Attaching files question
    ... pattern - sometimes the numbers are in some sort of order...in reverse ... I get the numbers in sequence but still in reverse ... >attach one at a time and do a File | Save in between for each attachment. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: Feature request: sorting a list slice
    ... having an explicit start/stop argument to reverse() and sort() ... slices of large lists. ... The user can't patch this as an extension on the fly, ...
    (comp.lang.python)