The hyphen package is Hyphen's native Python SDK for evaluating Toggle feature flags in Python applications and services.
Table of Contents
Installation
pip install hyphen
Authentication
The SDK requires an application id and an api key. See Get a Project's Public Key for where to find these in the Hyphen dashboard.
You can pass them directly or provide them via environment variables:
export HYPHEN_API_KEY="your_api_key"
export HYPHEN_APPLICATION_ID="your_application_id"
Initialization
from hyphen import FeatureToggle
toggle = FeatureToggle(
application_id='your_application_id',
api_key='your_api_key',
)
Usage
Retrieve a boolean feature flag with a fallback default value:
enabled = toggle.get_boolean('my-feature', default=False)
print('Feature enabled:', enabled)
See also
- GitHub: Hyphen/python-sdk
- Prefer OpenFeature? Use the Python provider.