Understand Python “yield”, An interrupt, A trap, A scissor
Some said “yield” is similar to the usage of “return”, the answer could be both yes and no. But one thing is certain:
yield is not
What is yield in Python?
The keyword “yield” working like a scissor cut the program into two parts.
The keyword “yield” working like an interrupt in OS, yield will return the control of the program back to the caller.
The keyword “yield” not only gives control back to the caller, but it can also…