
The original example is: numbers = (i for i in range(5)) assert 5 not in numbers sorted(numbers) I like this example. It provides an opportunity to improve the documentation. The problems goes away if we write any of the following numbers = [i for i in range(5)] numbers = tuple(i for i in range(5)) numbers = tuple(range(5)) numbers = list(range(5)) It also goes away if we write any of numbers = [0, 1, 2, 3, 4] numbers = (0, 1, 2, 3, 4) In fact, the various ways of making the problem go away produce either a list or a tuple 0, 1, 2, 3, 4. A simpler way to create the problem is x = iter(range(5)) 4 in x sorted(x) # returns an empty tuple. If instead we write x = range(5) then the problem goes away. I hope this helps. -- Jonathan