[Python-ideas] Propagating StopIteration value

Serhiy Storchaka storchaka at gmail.com
Mon Oct 8 23:02:36 CEST 2012


On 07.10.12 23:19, Guido van Rossum wrote:
> If this is just about iterator.chain() I may see some value in it (but
> TBH the discussion so far mostly confuses -- please spend some more
> time coming up with good examples that show actually useful use cases
> rather than f() and g() or foo() and bar())

Not I was the first one who showed an example with f() and g(). ;)  I 
only showed that it was wrong analogy.

Yes, first of all I think about itertools.chain(). But then I found all 
other iterator tools which also can be extended to better generators 
support. Perhaps.

I have only one imperfect example for use of StopIterator's value from 
generator (my patch for issue16009). It is difficult to find examples 
for feature, which appeared only recently. But I think I can find them 
before 3.4 feature freezing.

>   OTOH yield from is not primarily for iterators -- it is for
> coroutines. I suspect most of the itertools functionality just doesn't
> work with coroutines.

Indeed. But they work with subset of generators, and this subset can be 
extended. Please look at http://bugs.python.org/issue16150 (Implement 
generator interface in itertools.chain). Does it make sense?




More information about the Python-ideas mailing list