Recursive generator in Python 3.5

tpqnnd01 at gmail.com tpqnnd01 at gmail.com
Mon Oct 31 09:39:26 EDT 2016


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:

<code>
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'])))
</code>



More information about the Python-list mailing list