multirember&co

Anton Vredegoor anton.vredegoor at gmail.com
Wed Apr 18 18:51:59 EDT 2007


attn.steven.kuo at gmail.com wrote:

> Try it with
> 
> def test():
>     L = 'a', 1, 2, 'a'
>     it1, it2 = xsplitter(L, lambda x: x == 'a')
>     print it1.next()
>     print it2.next()
>     print it1.next()
>     print it2.next()
> 
> 
> The last print statement raises StopIteration...
> We, however, expected each iterator to contain
> two elements (one yielding 'a' then 'a', and
> the other yielding 1 then 2).

Ouch! I never understood much about generators anyway.

A.



More information about the Python-list mailing list