I try to ream a nested list by a generator in a recursive way. Here is my code:
def reaming(items):
print(items)
if items:
if isinstance(items,list):
a, *b = items
if isinstance(a,list):
reaming(a)
else:
yield a
reaming(b)
else:
yield items
for i in reaming([1,2,3,[4,5,6]]):
print(i)
I expected "1 2 3 4 5 6" will be returned. But I got only "1". Why?