# General Translation Python SDKs: extract_variables
URL: https://generaltranslation.com/it/docs/python/reference/functions/extract-variables.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: Filtra le chiavi GT riservate da un dizionario di opzioni per ottenere le variabili utente in General Translation Python. API Reference per extract_variables.

Restituisce un nuovo dizionario con solo le variabili di interpolation dell&#39;utente, escludendo le chiavi GT riservate di General Translation come `_context`. È l&#39;helper usato da [`t`](/docs/python/reference/functions/t), [`msg`](/docs/python/reference/functions/msg) e [`interpolate_message`](/docs/python/reference/functions/interpolate-message) per separare le variabili dalle opzioni.

## Panoramica [#overview]

Chiama `extract_variables` con un dizionario di opzioni. Restituisce un nuovo dizionario che contiene tutte le chiavi, tranne quelle GT riservate.

```python
from gt_i18n import extract_variables

extract_variables({"name": "Alice", "_context": "greeting"})
# → {"name": "Alice"}
```

Firma:

```python
extract_variables(options: dict[str, object]) -> dict[str, object]
```

Importa `extract_variables` da `gt_i18n`. Non è riesportato dai pacchetti del framework.

## Come funziona [#how-it-works]

* **Chiavi riservate.** Rimuove `_context`, `_id`, `_max_chars`, `__hash`, `__source` e `__fallback`.
* **Tutto il resto viene mantenuto.** Tutte le altre chiavi vengono mantenute, comprese le chiavi utente che iniziano con un singolo trattino basso (ad esempio `_name`).
* **Non distruttivo.** Restituisce un nuovo dizionario; l&#39;input rimane invariato.

## Parametri [#parameters]

| Parametro             | Descrizione                                                                  | Tipo                | Facoltativo | Predefinito |
| --------------------- | ---------------------------------------------------------------------------- | ------------------- | ----------- | ----------- |
| [`options`](#options) | Il dizionario completo delle opzioni, che può contenere chiavi GT riservate. | `dict[str, object]` | No          | —           |

### `options` [#options]

**Tipo** `dict[str, object]` · **Obbligatorio**

Il dizionario completo delle opzioni. Le chiavi GT riservate vengono rimosse; tutte le altre voci vengono mantenute.

## Restituisce [#returns]

**Tipo** `dict[str, object]`

Un nuovo dizionario da cui sono state rimosse le chiavi GT riservate.

## Esempio [#example]

```python
from gt_i18n import extract_variables

extract_variables({"_context": "x", "_id": "y", "_max_chars": 10})
# → {}

extract_variables({"_name": "Alice", "_context": "greeting"})
# → {"_name": "Alice"}
```

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
