Recursive generator in Python 3.5

tpqnnd01 at gmail.com tpqnnd01 at gmail.com
Mon Oct 31 14:47:58 EDT 2016


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.



More information about the Python-list mailing list