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 0
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()
> print(iter(N))
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)) # <
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 han