Itertools

Gonçalo Rodrigues op73418 at mail.telepac.pt
Tue Jul 29 09:22:10 EDT 2003


On Tue, 29 Jul 2003 08:32:14 -0400, "Ronald Legere"
<legere at ll.mit.edu> wrote:

>The new itertools stuff is pretty cool. One thing that bothers me though is
>that
>there seems to be no way to copy an iterator. How does one work around this?
>Is
>there a trick that I am missing?
>
>Without being able to 'split' an iterator, I can't
>think of how to do some of the cool things you can do with lazy lists in
>Haskell. It seems
>quite often you want to be able to do this 'splitting', and if I
>had more coffee I would post an example :) The ones I
>can think of are also defined recursively, which is another kettle of fish.
>

Iterables can be more far general than lazy lists: think of a socket
as an iterable churning out lines of text, for example. How would one
go about copying these general iterables? 

You can take slices of iterables, though - can't remember the name,
islice? But since you don't know how to take copies of iterables in
general this may not be that useful.

> But I hope that someone knows
>what I am talking about and has thought of a way...
>Cheers!
>

With my best regards,
G. Rodrigues




More information about the Python-list mailing list