# libtmux.Session.search_panes

- **Module:** libtmux
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/38e368c11117fb4aeb2f082d552cd4f210eae06a/src/libtmux/session.py#L342
- **Page:** https://libtmux.org/en/py/stable/reference/libtmux-session-search_panes/

```
libtmux.Session.search_panes(
    self, filter: str | None = None, # noqa: A002
) -> QueryList[Pane]
```

Panes in this session, optionally filtered by tmux.

Like :attr:`Session.panes` but with a ``filter`` kwarg passed to
[`$ tmux list-panes -s -t <session> -f <filter>`](/en/tmux/latest/manual/list-panes/).

## Examples

```python
>>> target_pane = session.active_window.split()
>>> matches = session.search_panes(
...     filter=f'#{{m:{target_pane.pane_id},#{{pane_id}}}}'
... )
>>> [p.pane_id for p in matches] == [target_pane.pane_id]
True
```

## Parameters

- `filter` (`str | None`): tmux format expression (``-f`` flag).
tmux silently expands a malformed filter (unclosed
``#{...}``, unknown format token) to empty, which the
filter treats as false — every row is suppressed and no
stderr is emitted. A bad filter is
indistinguishable from "filter matched nothing"; verify
filter syntax against the FORMATS section of ``tmux(1)``. Warning: (added 0.57)
- `# noqa: A002`

## In other ports

### Filter a session's panes with a tmux expression

- Go: [`tmux.Session.SearchPanes`](/en/go/latest/reference/tmux-session-searchpanes/) (method)
- C#: [`LibTmux.Session.SearchPanesAsync`](/en/csharp/latest/reference/libtmux-session-searchpanesasync/) (method)
