Inline Immediately Yielded Variable
Documentation Index
Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt
Use this file to discover all available pages before exploring further.
Sourcery refactoring id: inline-immediately-yielded-variable
Section titled “Sourcery refactoring id: inline-immediately-yielded-variable”Description
Section titled “Description”Inline variable that is immediately yielded
Before
Section titled “Before”def f(a): b = a + 1 yield b
def g(a): b = [1, 2, 3] yield from bdef f(a): yield a + 1
def g(a): yield from [1, 2, 3]Explanation
Section titled “Explanation”Yielding the result directly shortens the code and makes it more readable.