-
Install the Python SDK with
pip
pip install ldclient-py
-
Create a new LDClient with your API key:
client = LDClient("your_api_key")
-
Create a new feature flag on your dashboard
-
In your application code, use the feature's key to check wthether the flag is on for each user:
if client.toggle("your.flag.key", {"key": "[email protected]"}, False): # application code to show the feature else: # the code to run if the feature is off
-
Install requirements (run-time & test):
pip install -r requirements.txt pip install -r test-requirements.txt
-
Run tests:
$ py.test
Check out our documentation for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the complete reference guide for this SDK.