What about an EXPLICIT naming scheme for built-ins?

Jp Calderone exarkun at divmod.com
Fri Sep 3 16:05:43 CEST 2004


Carlos Ribeiro wrote:
> Mostly agreed. There is an inconsistence, as sorted() and reversed()
> should return both the same type of result - be it a sequence or a
> iterator.
> 
> I propose a slightly different approach. First, proposing a generic
> naming scheme for built-ins is an ambitious goal, to say the least. I
> suggest to keep the focus on this particular issue, if only to avoid a
> lot of debate and flaming. So -- keeping in mind my own suggestion --
> I would like to focus on the particular case at hand:
> 
> 1) sorted() and reversed() should return sequences. So sorted() stays
> like it, and reversed() meaning is changed. Now, that could
> potentially break a lot of code, but probably this is not going to
> happen -- because in most situations, reversed() is getting called

   They are new.  There is no reason to worry about breaking 
compatibility.  Why sequences and not iterators?  I would prefer the 
latter, and it is in keeping with many other recent language 
developments (generator comprehensions, itertools module, etc).

> 
> 2) add two new builtins, called respectively xsorted() and
> xreversed(), as the iterator versions of sorted() and reversed(). This
> way we keep the existing naming convention for range() and xrange().

   -1.  The "x" prefix means "this is a hack".  xrange() will become 
range() in Python 3.0.  The xreadlines module is deprecated already.

   Jp



More information about the Python-list mailing list