Top "Yield" questions

yield is (1) a keyword that facilitates creation of generator functions, (2) a Ruby statement to transfer control from one coroutine to another, (3) a Java statement used to yield a value from a switch expression.

Recursion using yield

Is there any way to mix recursion and the yield statement? For instance, a infinite number generator (using recursion) would …

python python-2.7 recursion yield
How to use 'yield' inside async function?

I want to use generator yield and async functions. I read this topic, and wrote next code: import asyncio async …

python yield python-3.5 python-asyncio
Return and yield in the same function

What exactly happens, when yield and return are used in the same function in Python, like this? def find_all(…

python yield
Converting "yield from" statement to Python 2.7 code

I had a code below in Python 3.2 and I wanted to run it in Python 2.7. I did convert it (have …

python generator python-2.x yield yield-from
Yield String from List[Char]

I have a l: List[Char] of characters which I want to concat and return as a String in one …

scala yield yield-return
Python: generator expression vs. yield

In Python, is there any difference between creating a generator object through a generator expression versus using the yield statement? …

python python-3.x generator yield
Where to use yield in Python best?

I know how yield works. I know permutation, think it just as a math simplicity. But what's yield's true force? …

python yield
How to yield results from a nested generator function?

I have a function which yields results as it downloads them. For the purposes of this question, lets say I …

python function nested generator yield
Why can't yield return appear inside a try block with a catch?

The following is okay: try { Console.WriteLine("Before"); yield return 1; Console.WriteLine("After"); } finally { Console.WriteLine("Done"); } The finally block …

c# exception yield
How does a threading.Thread yield the rest of its quantum in Python?

I've got a thread that's polling a piece of hardware. while not hardware_is_ready(): pass process_data_from_hardware() …

python multithreading yield