# libtmux._internal.query_list.QueryList.get

- **Module:** libtmux._internal.query_list.QueryList
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/036c521c4b83ce6e434eb50afe2a0d08a6a05e46/src/libtmux/_internal/query_list.py#L552
- **Page:** https://libtmux.org/reference/py/libtmux-_internal-query_list-querylist-get/

```
libtmux._internal.query_list.QueryList.get(self, matcher: Callable[[T], bool] | T | None = None, default: t.Any | None = no_arg, kwargs: t.Any) -> T | None
```

Retrieve exactly one object.

## Parameters

- `self`
- `matcher` (Callable[[T], bool] | T | None) — Same matcher :meth:`filter` takes.
- `default` (t.Any | None) — Returned instead of raising when *nothing* matches.
- `kwargs` (t.Any)

## Returns

object
    The single match, or *default* when there is no match and one was
    given.

## Raises

- `ObjectDoesNotExist` — When nothing matches and no *default* was passed.
- `MultipleObjectsReturned` — When more than one object matches. A *default* does not suppress
this: it stands in for an object that is absent, and an ambiguous
lookup is not an absent one.

## Example

```python
>>> from libtmux._internal.query_list import QueryList
>>> from libtmux import exc
>>> qs = QueryList([{"pane_id": "%0"}, {"pane_id": "%0"}, {"pane_id": "%1"}])
```

## Example

```python
>>> qs.get(pane_id="%1")
{'pane_id': '%1'}
```

## Example

A lookup that matches nothing says what it went looking for:

```python
>>> try:
...     qs.get(pane_id="%9")
... except exc.ObjectDoesNotExist as e:
...     print(e)
No objects found: pane_id='%9'
```

## Example

```python
>>> qs.get(pane_id="%9", default=None) is None
True
```

## Example

A lookup that matches several says how many, and for what:

```python
>>> try:
...     qs.get(pane_id="%0")
... except exc.MultipleObjectsReturned as e:
...     print(e)
Multiple objects returned (2): pane_id='%0'
```
