[Python-checkins] r63170 - python/trunk/Doc/library/functions.rst

Georg Brandl g.brandl at gmx.net
Mon May 12 19:50:14 CEST 2008


Guido van Rossum schrieb:
> On Mon, May 12, 2008 at 10:09 AM, Raymond Hettinger <python at rcn.com> wrote:
>> [Georg]
>>
>>
>> > Fix parameter name for enumerate().
>> >
>>
>>
>> > -.. function:: enumerate(iterable)
>> > +.. function:: enumerate(sequence)
>> >
>> > -   Return an enumerate object. *iterable* must be a sequence, an
>> :term:`iterator`, or some
>> >
>>
>>  I don't understand this change.  Why is *iterable* not correct?
>>  Elsewhere, we've taken sequence to mean something with __getitem__ and
>> __len__
>>  while iterable means something that responds nicely to iter(obj).
> 
> I'm with Raymond -- in 3.0 we even added Iterable to the small set of
> standard ABCs. A *Sequence* is defined there too, and has a much more
> elaborate API (e.g. slicing and indexing). The whole point of things
> like enumerate() is that it *doesn't* require all that -- it is
> anything for which iter() can return an iterator. (And yes, *Iterator*
> is another ABC in 3.0.)

That may be right, but enumerate() takes keyword arguments and the keyword
name for that parameter is "sequence". (We can of course change that for
Py3k, if you like.)

Georg

-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.



More information about the Python-checkins mailing list