# yield

say it: **“YEELD”** **/jiːld/**

Hands back one value from a generator and pauses until the next one is needed.

## What does `yield` do?

`yield` hands one value back from a generator and pauses there. The next time a value is asked for, the function carries on from where it stopped.

```python
def read_orders(path):
    with open(path) as file:
        for line in file:
            yield line.strip()     # one order at a time

for order in read_orders("orders.txt"):
    print(order)
```

Level: Freelancer · [More Python terms at this level](https://www.ask-codey.com/glossary?category=python&level=4)

Updated: November 17, 2026

## In other subjects

- [yield in JavaScript](https://www.ask-codey.com/glossary/yield-javascript)

Source: https://www.ask-codey.com/glossary/yield
