I've been staring at this for a little while:

from itertools import product

class Naturals:
    def __iter__(self):
        i = 1
        while True:
            yield i
            i += 1

N = Naturals()
print(iter(N))
print(product(N))  # <--- hangs

When I run the above the call to product hangs but I can't see why. I
would expect that since I'm not iterating over the product it would
just call iter(N) but clearly not since iter(N) returns a generator
instantly where as product(N) hangs.

What am I missing?

Oscar
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to