[Python-ideas] Aid reiteration with new class: gfic

Terry Reedy tjreedy at udel.edu
Sun Jun 21 22:12:01 CEST 2009


Paul Moore wrote:
> 2009/6/21 Terry Reedy <tjreedy at udel.edu>:
>> Nick Coghlan wrote:
>>> 1. I've never seen a function parameter spec'ed as iterable vs
>>> reiterable. It's always iterable vs sequence.
>> The latter could be over-spec'ed because people are used to that being the
>> choice, or because 'sequence' is being used as a synonym for 'reiterable'
>> even though it implies more than is needed.
> 
> OTOH, it could be because "reiterable" isn't a commonly used concept
> in Python. It's not entirely clear to me why this is, maybe it's
> because it's not actually that useful, maybe it's because it's hard to
> define clearly, or maybe there's another reason.

My thought is this. iterable and iterator are separate and complementary 
concepts: a collection (concrete or virtual) that can be iterated over 
and the thing that does the iterating. For (great) programming 
convenience, Python iterators were made into a subcategory of an 
expanded 'iterable' category.

In informal discourse, people sometimes, perhaps often, use 'iterable' 
in the narrower conceptual sense rather than the broader 
Python-implementation sense. Or they sort of mean it in the narrow sense 
but it does not matter because the statement also applies to iterators 
once they are made into iterables.

To be clear in a Python context, when one wants to say something that 
does not apply to iterators, one can qualify 'iterable' to 'non-iterator 
iterable' or, less commonly at present, use the synonym 'reiterable'. I 
say synonym because any Python iterable object is reiterable as long as 
the information defining it is not altered, destroyed, or 'forgotten' by 
the process of iteration.

> But to some extent this whole thread has the same sort of "solution
> looking for a problem" feel that earlier threads about reiterability
> have had.

It is a solution to a conceptual and didactic problem that I offered for 
*possible* practical use. But I am not pushing it.

Terry Jan Reedy





More information about the Python-ideas mailing list