How to write this iterator?

severa at severa at
Mon Sep 19 14:15:45 CEST 2005

Sorry, my description was not very good, I meant something behaving as:

>>>for x in example: print x,

a 1 X b 2 Y c 3 4 5

or for that append() method,

>>>example=Liter("abc", "12345")
>>>for i in range(3): print,

a 1 b

>>>for x in example: print x,

2 c X 3 Y 4 5

Hope this clarifies what I mean

Best regards

>A generator version:
>def iterconcat (collectionlist):
>     for collection in collectionlist:
>         for element in collection:
>             yield element
>Extending collectionlist at runtime will work only with lists and 
>similar collections. And you'll need to keep a reference to it as well. 
>And it would be called after all the others, which matches your 
>description, but not your code.

More information about the Python-list mailing list