Re: itertools product(infinite iterator) hangs

2019-09-15 Thread Oscar Benjamin
On Sat, 14 Sep 2019 at 07:22, ast wrote: > > Le 14/09/2019 à 04:26, Oscar Benjamin a écrit : > > > > What am I missing? > > here is a pseudo code for product: > > def product(*args, repeat=1): > # product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy > # product(range(2), repeat=3) --> 000

Re: itertools product(infinite iterator) hangs

2019-09-15 Thread Oscar Benjamin
On Sat, 14 Sep 2019 at 03:26, Oscar Benjamin wrote: > > 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() >

Re: itertools product(infinite iterator) hangs

2019-09-14 Thread ast
Le 14/09/2019 à 04:26, Oscar Benjamin a écrit : 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)) #

itertools product(infinite iterator) hangs

2019-09-13 Thread Oscar Benjamin
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