# libtmux.Format.escape

- **Module:** libtmux
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/d2a146c9a045437b92013d65943b7ac70013fa24/src/libtmux/formats.py#L271
- **Page:** https://libtmux.org/en/py/latest/reference/libtmux-format-escape/

```
libtmux.Format.escape(cls, text: str | Format) -> Format
```

Return a format that tmux expands back to *text*.

The result stays literal inside an expression such as a conditional
or comparison, though not inside ``#(...)``, where tmux counts
parentheses for a shell command. A :class:`Format` is returned
unchanged.

## Parameters

- `text` (`str | Format`)

## Examples

```python
>>> Format.escape("x#S")
Format('x#{a:35}S')
>>> Format.escape(Format("#S"))
Format('#S')
```

Compare a window name with user text:

```python
>>> user_text = "a,b"
>>> Format("#{==:#{window_name},") + Format.escape(user_text) + Format("}")
Format('#{==:#{window_name},a#{a:44}b}')
```
