[Python-ideas] Aid reiteration with new class: gfic
yoavglazner at gmail.com
Fri Jun 19 16:28:54 CEST 2009
On Fri, Jun 19, 2009 at 6:11 AM, Steven D'Aprano <steve at pearwood.info>wrote:
> On Fri, 19 Jun 2009 07:02:12 am Terry Reedy wrote:
> As I see it, the correct solution for "my function needs to iterate over
> an iterable twice" is not to expect the caller to pass a sequence, but
> to convert the iterable to a sequence inside your function:
> def function(iterable):
> # Iterate over iterable twice
> L = list(iterable)
> for _ in (1, 2):
> for x in L:
As I see it the correct solution is
# Iterate over iterable twice
L = iterable.clone() #can be done?
for x in L:
for x in iterable :
this way i avoid endless iterators...
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas