Re: Recursive generator in Python 3.5
Thanks for your detail explanation, my problem may be the 'return' keyword. I confuse at the point that return come after yield keyword, I wonder what if in case this code do not have the 1st return. So, when i try to delete the 1st return, the code run with error (the list out of range). This is actual clear from your example above, when the 1st return is delected, the statement flow shall be from (yield '') to (yield i + tmp) when the Next() is called. This behaviour shall reach to a statement is: for i in [][0] that shall raise an error: list index out of range. -- https://mail.python.org/mailman/listinfo/python-list
Re: Recursive generator in Python 3.5
Hi Chris, Please see the exampl I just got it below, this is the Tower of Hanoi with recursive generator but it do not have the 'return' here, do you have the advice for this term: def A001511(): yield 1 b=1 for x in A001511(): yield x+1 yield 1 trial=A001511() for i in range(10): a=next(trial) print(a) -- https://mail.python.org/mailman/listinfo/python-list
Re: Recursive generator in Python 3.5
Hi ChrisA, Thank you so much for sharing this point, I just concern to the point that: normally, I found that the generator (it may be recursive generator also) do not apply the "return" keyword, just the yield only. But when I delete one or both of "return" keyword above, the code do not action. What is the concern here, could you share more experience on that, -- https://mail.python.org/mailman/listinfo/python-list
Recursive generator in Python 3.5
I have some confuse about the recursive generator where the code mixing Yield and return keywork as below. I understand that "return" keywork just raise StopIteration exception but can not understanding in depth, so, could some one explain me about the actual function of two "return" keyworks in case it have other function and mechanism of for running this code segment below: def fg(args): if not args: yield "" return for i in args[0]: for tmp in fg(args[1:]): yield i + tmp return print(list(fg(['abc', 'xyz', '123']))) -- https://mail.python.org/mailman/listinfo/python-list