iterator clone

Yosifov Pavel bulg at ngs.ru
Sun Jul 13 21:51:19 EDT 2008


> Well, I think Python's iterators, especially the generators, are beautiful.
> More importantly, I think there is no general way to make iterators
> copyable, regardless of the programming language. The problem is that most
> of the useful ones depend on external state.
>
> Peter

Hmm, but tee() de facto do it (clone iterator) and ignore side-effects
of iterator ("external" state). And tee() create independent
**internal** state of iterator (current position). But **external**
state - is headache of programmer. So, iterator/generator have to be
method for copy itself (the tee() implementation) or be "re-
startable". Why not?

Concrete problem was to generate iterators (iterator of slices). It
was solved with ReIter.

--Best regards,
--pavel



More information about the Python-list mailing list