ARTICLE AD BOX
Consider this Python snippet:
iter1 = range(3) iter2 = range(2) print([(e1, e2) for e1 in iter1 for e2 in iter2])This displays 3x2 = 6 tuples, as expected:
[(0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (2, 1)]Fine! Now, let's try this slight variant:
iter1 = iter(range(3)) iter2 = iter(range(2)) print([(e1, e2) for e1 in iter1 for e2 in iter2])The output is surprisingly different:
[(0, 0), (0, 1)]This result looks wrong or, for the least, inconsistent. This behaviour occurs at least on Python 2.7, 3.12 and 3.14.
Notes:
Before opening a Python issue ticket, I'd like to have some feedback on this odd phenomenon, which I consider as a plain bug.
