itertools cycle() docs question

Chris Angelico rosuav at gmail.com
Thu Aug 22 11:59:08 EDT 2019


On Fri, Aug 23, 2019 at 1:41 AM Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:
>
> On Wed, 21 Aug 2019 12:52:44 -0700, Tobiah <toby at tobiah.org> declaimed the
> following:
>
> >
> >I see.  What is an example of an iterable that is not reusable?
>
>
> >>> x = range(5)
> >>> x
> range(0, 5)
> >>>
>

>>> x = range(0, 5)
>>> list(x)
[0, 1, 2, 3, 4]
>>> list(x)
[0, 1, 2, 3, 4]
>>> list(x)
[0, 1, 2, 3, 4]
>>> list(x)
[0, 1, 2, 3, 4]

Perfectly reusable. There are plenty of others that aren't, but that one is.

ChrisA



More information about the Python-list mailing list