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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4