Re: Recursive generator in Python 3.5

2016-11-02 Thread congloi1990
Thank you so much, this all clear for me now -- https://mail.python.org/mailman/listinfo/python-list

Re: Recursive generator in Python 3.5

2016-10-31 Thread Gregory Ewing
tpqnn...@gmail.com wrote: def fg(args): if not args: yield "" return for i in args[0]: for tmp in fg(args[1:]): yield i + tmp return The final return is redundant, since there is an implicit return at the end, just like an ordinary function. The other one is just perfor

Re: Recursive generator in Python 3.5

2016-10-31 Thread tpqnnd01
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

Re: Recursive generator in Python 3.5

2016-10-31 Thread Steve D'Aprano
On Tue, 1 Nov 2016 12:39 am, tpqnn...@gmail.com wrote: > 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 exp

Re: Recursive generator in Python 3.5

2016-10-31 Thread Chris Angelico
On Tue, Nov 1, 2016 at 1:50 AM, wrote: > > 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(): >

Re: Recursive generator in Python 3.5

2016-10-31 Thread tpqnnd01
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

Re: Recursive generator in Python 3.5

2016-10-31 Thread Chris Angelico
On Tue, Nov 1, 2016 at 1:03 AM, wrote: > 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 > b

Re: Recursive generator in Python 3.5

2016-10-31 Thread tpqnnd01
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 actio

Re: Recursive generator in Python 3.5

2016-10-31 Thread Chris Angelico
On Tue, Nov 1, 2016 at 12:39 AM, wrote: > 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 abo

Recursive generator in Python 3.5

2016-10-31 Thread tpqnnd01
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