[Python-Dev] Re: PEP 279 (original) (raw)
Raymond Hettinger python@rcn.com
Tue, 2 Apr 2002 00:28:45 -0500
- Previous message: [Python-Dev] Re: PEP 279
- Next message: [Python-Dev] Re: PEP 279
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 . 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 .
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:
- enumerate
- countoff
- indexed
- itercount
OTOH, no one has ever accused me of having good taste
Raymond Hettinger
- Previous message: [Python-Dev] Re: PEP 279
- Next message: [Python-Dev] Re: PEP 279
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]