<commit_before>---
id: python_sdk
title: Python SDK
---

> You will need your `API URL` and your `API token` in order to connect the Client SDK to you Unleash instance. You can find this information in the “Admin” section Unleash management UI. [Read more](../user_guide/api-token)

```python
from UnleashClient import UnleashClient

    client = UnleashClient(
        url="<API url>",
        app_name="my-python-app",
        custom_headers={'Authorization': '<API token>'})

    client.initialize_client()

    client.is_enabled("unleash.beta.variants")
```

## Checking if a feature is enabled {#checking-if-a-feature-is-enabled}

Check a feature's status:

```Python title="Check whether a feature is enabled"
client.is_enabled("my_toggle")
```

To supply application context, use the second positional argument:

```Python title="Check whether a feature is enabled for the given context"
app_context = {"userId": "<EMAIL>"}
client.is_enabled("user_id_toggle", app_context)
```

### Fallback function and default values

You can specify a fallback function for cases where the client doesn't recognize the toggle by using the `fallback_function` keyword argument:

```Python title="Check a feature status, using a fallback if the feature is unrecognized."
def custom_fallback(feature_name: str, context: dict) -> bool:
    return True<commit_msg>Fixing indentation of Python example (#1794)<commit_after>---
id: python_sdk
title: Python SDK
---

> You will need your `API URL` and your `API token` in order to connect the Client SDK to you Unleash instance. You can find this information in the “Admin” section Unleash management UI. [Read more](../user_guide/api-token)

```python
from UnleashClient import UnleashClient

client = UnleashClient(
    url="<API url>",
    app_name="my-python-app",
    custom_headers={'Authorization': '<API token>'})

client.initialize_client()

client.is_enabled("unleash.beta.variants")
```

## Checking if a feature is enabled {#checking-if-a-feature-is-enabled}

Check a feature's status:

```Python title="Check whether a feature is enabled"
client.is_enabled("my_toggle")
```

To supply application context, use the second positional argument:

```Python title="Check whether a feature is enabled for the given context"
app_context = {"userId": "<EMAIL>"}
client.is_enabled("user_id_toggle", app_context)
```

### Fallback function and default values

You can specify a fallback function for cases where the client doesn't recognize the toggle by using the `fallback_function` keyword argument:

```Python title="Check a feature status, using a fallback if the feature is unrecognized."
def custom_fallback(feature_name: str, context: dict) -> bool:
    return True
{'fraction_non_alphanumeric': 0.10881593507930652, 'fraction_numerical': 0.0014754703061600886, 'mean_word_length': 4.947368421052632, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3488189', 'n_tokens_mistral': 799, 'n_tokens_neox': 759, 'n_words': 298}