[Python-ideas] Consider making enumerate a sequence if its argument is a sequence

Andrew Barnert abarnert at yahoo.com
Thu Oct 1 08:34:34 CEST 2015


On Sep 30, 2015, at 22:59, Akira Li <4kir4.1i at gmail.com> 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):
> 
> - does it mean that all iterables must be finite?
> - do we need a special word to describe what list() accepts?
> 
> set(iterable):
> 
> - does it mean that all iterables must yield hashable items?
> - do we need a special word to describe what set() accepts?
> 
> dict(iterable):
> 
> - does it mean that all iterables must yield pairs?
> - do we need a special word to describe what dict() accepts?
> 
> 
> You've got the idea: the word *iterable* may be used in the context when
> not all iterables are accepted.
> 
>  https://mail.python.org/pipermail/python-ideas/2015-October/036692.html

This is a link to a reply where you pasted exactly the same text as in this reply—and in a third one. What is that supposed to mean?

I feel like you must be trying to get across something really important here, and it's my fault for not getting it, but I still can't get it. Can you try rewording it instead of just pasting the same text again and/or a link to the same text?

If it helps, let me try to ask specific questions:

Are you arguing one of the following:

 * there is no such thing as an iterable that isn't an iterator, or an iterable that is repeatable, or an iterable that provides a new iterator each time iter is called?
 * there are such things, but no corresponding property that can be used to characterize a set?
 * that such sets do exist, but are never useful to discuss?
 * that such sets may be useful to discuss, but the names I (and Terry and others) came up with are unhelpful?

More concretely: the documentation for dict views goes out of its way to point out that these are not iterators, but a different kind of iterable that's more like a sequence (presumably meaning at least one of the three things above). But it does so inaccurately, by saying they are sequences, which is not true. How could it be rewritten to get that point across accurately, but still concisely and readably?


More information about the Python-ideas mailing list