How to write this iterator?
severa at sophia.dtp.fmph.uniba.sk
severa at sophia.dtp.fmph.uniba.sk
Mon Sep 19 08:15:45 EDT 2005
Sorry, my description was not very good, I meant something behaving as:
>>>example=Liter("abc","12345","XY")
>>>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 example.next(),
a 1 b
>>>example.append("XY")
>>>for x in example: print x,
2 c X 3 Y 4 5
Hope this clarifies what I mean
Best regards
Pavol
>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.
>
>Daniel
More information about the Python-list
mailing list