[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

itertools cycle() docs question

On Thu, Aug 22, 2019 at 6:55 AM Dan Sommers
<2QdxY4RzWzUUiLuE at potatochowder.com> wrote:
> On 8/21/19 2:32 PM, Calvin Spealman wrote:
> > The point is to demonstrate the effect, not the specific implementation.
> Once you've gone through the iterable once, it's falsey,
> which means that the while loop will end.  But if you copy
> all the elements to a real list, then the while loop is
> infinite.

Hmm, not all iterables are falsey after exhaustion. The point of the
"while saved" is to skip the loop if you cycle nothing, but you can't
depend on the four line version.