About 1,000,000 results
Open links in new tab
  1. python - itertools.repeat VS itertools.cycle - Stack Overflow

    Apr 19, 2016 · Is there any difference between itertools.repeat(n) and itertools.cycle(n)? As it seems, they produce the same output. Is one more efficient to use in a situation where I need …

  2. python 3.x - itertools.cycle ().next ()? - Stack Overflow

    May 19, 2014 · Well, I was using itertools.cycle ().next () method with Python 2.6.6, but now that I updated to 3.2 I noticed that itertools.cycle () object has no method next (). I used it to cycle a …

  3. python - Is there an elegant way to cycle through a list N times via ...

    Apr 26, 2012 · Is there an elegant way to cycle through a list N times via iteration (like itertools.cycle but limit the cycles)? Asked 13 years, 8 months ago Modified 8 months ago …

  4. python - Implementing my own Cycle function ( mocking …

    Jun 30, 2023 · Am new to Python and am trying to implement my own Cycle method mocking itertools.cycle method. I have written the following code. It gives the output, but with an …

  5. itertools: cycle through several lists N times via iteration

    Mar 21, 2023 · itertools: cycle through several lists N times via iteration Asked 2 years, 8 months ago Modified 2 years, 8 months ago Viewed 143 times

  6. python - How to break cycle after a specific number of iterations in ...

    Oct 14, 2020 · from itertools import cycle a = [1,2,3] for i in cycle(a): print (i) if i == 5: break what I expect is 123,123,123,123,123. it cycling 5 times before breaking. Instead it keeps going …

  7. `Itertools.cycle`: most pythonic way to take multiple steps?

    `Itertools.cycle`: most pythonic way to take multiple steps? Asked 8 years, 6 months ago Modified 8 years, 6 months ago Viewed 2k times

  8. How do I use itertools.cycle with multiple objects?

    Nov 11, 2015 · How do I use itertools.cycle with multiple objects? Asked 10 years, 2 months ago Modified 10 years, 2 months ago Viewed 389 times

  9. How to specify where to start in an itertools.cycle function

    Feb 25, 2017 · How to specify where to start in an itertools.cycle function Asked 8 years, 10 months ago Modified 4 years, 9 months ago Viewed 4k times

  10. itertools.cycle(iterable) vs while True - Stack Overflow

    3 You're right, itertools.cycle isn't of great interest here over the classical while True loop. On the other hand, it's of great help in infinite generator comprehensions, where you cannot create an …