> ## 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.

# Inline Immediately Yielded Variable

#### Sourcery refactoring id: `inline-immediately-yielded-variable`

#### Description

Inline variable that is immediately yielded

#### Before

```python
def f(a):
    b = a + 1
    yield b


def g(a):
    b = [1, 2, 3]
    yield from b
```

#### After

```python
def f(a):
    yield a + 1


def g(a):
    yield from [1, 2, 3]
```

#### Explanation

Yielding the result directly shortens the code and makes it more readable.

#### Related refactorings

- [inline-immediately-returned-variable](/reference/refactorings/python/inline-immediately-returned-variable/)
