[Python-ideas] Consider making enumerate a sequence if its argument is a sequence
Terry Reedy
tjreedy at udel.edu
Fri Oct 2 09:19:24 CEST 2015
On 10/1/2015 1:59 AM, Akira Li wrote:
> Random832 <random832 at fastmail.com> writes:
>
>> Akira Li <4kir4.1i at gmail.com> writes:
>>> I don't remember ever using "non-iterator iterable". "non-iterator
>>> iterable" does not qualify as more specific. You need to introduce new
>>> requirements to the type for that.
>>
>> The question is, how do you *simply* state the very common requirement
>> for an iterable to not behave in a specific undesirable way that all
>> iterators do, and that it is very uncommon for any iterable other than
>> an iterator to do? Are you opposed to having a word for this concept at
>> all, or do you just not like the terms other people are suggesting?
>
> That term is **iterable**. As I already said:
>
> Specific application may use more specific requirements e.g.:
>
> list(iterable):
finite_iterable
> - does it mean that all iterables must be finite?
> - do we need a special word to describe what list() accepts?
>
> set(iterable):
iterable_of_hashables
> - does it mean that all iterables must yield hashable items?
> - do we need a special word to describe what set() accepts?
>
> dict(iterable):
iterable_of_pairs (whose first member is hashable)
> - does it mean that all iterables must yield pairs?
> - do we need a special word to describe what dict() accepts?
Whatever word is used in the signature, the description should be in the
doc and docstring, preferable in the first line.
Return a list with members from a finite iterable.
Return a set with members from an iterable of hashable objects.*
Return a string joining items from an iterable of strings.
*Also, equality between object should be transitive
> You've got the idea: the word *iterable* may be used in the context when
> not all iterables are accepted.
Right. Each one should be documented properly.
--
Terry Jan Reedy
More information about the Python-ideas
mailing list