[issue43450] List amnesia

Florian Bruhin report at bugs.python.org
Tue Mar 9 14:17:16 EST 2021


Florian Bruhin <python.org at the-compiler.org> added the comment:

This is not a bug. itertools.product returns an iterator: https://docs.python.org/3/glossary.html#term-iterator

Quoting from there:

> [...] every iterator is also iterable and may be used in most places where other iterables are accepted. One notable exception is code which attempts multiple iteration passes. A container object (such as a list) produces a fresh new iterator each time you pass it to the iter() function or use it in a for loop. Attempting this with an iterator will just return the same exhausted iterator object used in the previous iteration pass, making it appear like an empty container.

----------
nosy: +The Compiler

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43450>
_______________________________________


More information about the Python-bugs-list mailing list