What about an EXPLICIT naming scheme for built-ins?

Andrew MacIntyre andymac at bullseye.apana.org.au
Sat Sep 4 01:15:56 CEST 2004

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 at bullseye.apana.org.au  (pref) | Snail: PO Box 370
        andymac at pcug.org.au             (alt) |        Belconnen ACT 2616
Web:    http://www.andymac.org/               |        Australia

More information about the Python-list mailing list