itertools cycle() docs question
Chris Angelico
rosuav at gmail.com
Wed Aug 21 17:02:27 EDT 2019
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.
ChrisA
More information about the Python-list
mailing list