What about an EXPLICIT naming scheme for built-ins?

Carlos Ribeiro carribeiro at gmail.com
Mon Sep 6 09:18:26 EDT 2004


On 6 Sep 2004 12:18:24 GMT, Antoon Pardon <apardon at forel.vub.ac.be> wrote:
> But I think it would be nice to have a naming convention that made
> it clear whether you got an iterator or a sequence (list).
> 
> If we would use names like ranging, reversing ... when an iterator
> is returned and sorted, ... when a sorted copy of the sequence
> is returned I think that would greatly help people in understanding
> what is going on.

After reading all the arguments, it is clear that there are two ways
to look at the naming situation.

1) If you look it from a structured point of view, there are four
possible combinations of sorted() and reversed(), depending upon the
return value -- a list or an iterator. In this case, the names for the
current builtins should be sorted() and ireversed().

2) If you take a more relaxed look and want to give simple names to
solve the most useful and common situations, then the current naming
scheme is ok, with a single exception: you can't used reversed() to
assign the reversed list to another variable. That's the only catch.

The case for (1) would be stronger if the proposed naming didn't had
any problems of its own. Just to mention a few problems with the
ireversed() name:

-- It smells something out of hungarian notation, which many people
don't like at all.

-- The "i" prefix is overloaded just too many times (specially if you
consider upper and lower case variations) -- it can mean integer,
interface, or iterable (in the case of itertools).

--  I don't know about any other opinions, but the "i" prefix just
doesn't sound right to me, pretty much because ireversed() sounds like
a different word with a different meaning, not like "i-reversed". In
linguistic terms, it *is* a problem because the "i" prefix does have a
meaning of its own -- as in reversible --> irreversible. And
xreversed() (my original choice) is out of question, as xrange is
being deprecated now.


In the end, it may end up being a matter of choice and personal taste.
ireversed() is more consistent (accordingly to line of reasoning (1))
but doesn't *sound* as good as reversed(). I just can't come up with a
different naming scheme that is both readable and simple to remember.
I fear that it's too late to discuss it properly now.

-- 
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: carribeiro at gmail.com
mail: carribeiro at yahoo.com



More information about the Python-list mailing list