[Python-Dev] Re: PEP 279
Raymond Hettinger
python@rcn.com
Tue, 2 Apr 2002 00:28:45 -0500
From: "Tim Peters" <tim.one@comcast.net>
> > So now I'd like to choose between enumerate() and indexer(). Any
> > closing arguments?
>
> I'm leaving that quote anonymous so nobody gives it more or less weight
than
> it deserves <wink>. I prefer enumerate(), because a transitive verb is
more
> appropriate than a noun. OTOH, enumerate() is just a fancy pants way of
> saying "countoff()", which is nicely confusable with operator.countOf if
> you're tired <wink>.
>
I agree. Enumerate is a direct, unequivocable verb that speaks directly to
the idea of sequentially assigning numbers to things.
Countoff is cool, but is a little colloquial. Also, any of the words
incorporating count (including itercount and countoff) have a subtle
implicit suggestion of counting from one rather than zero -- "firstly, let's
take item zero ..."
While indices have a clear meaning in Python, the old Dbase and SQL part of
me is a little bugged by index(), indexed(), indexer() since sequential
files are not at all like indexed files. When I index a database, sorting
takes place. When I index a collection, sequencing is applied. Much
different.
As a part of speech, indexer() doesn't work as well in a sentence:
for linenum, line in indexer(file): ... # yuck!
Summary, I think we're down to subtle differences and have the following
preference order:
1. enumerate
2. countoff
3. indexed
4. itercount
OTOH, no one has ever accused me of having good taste <wink>
Raymond Hettinger