| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Install the Python SDK with pip
pip install ldclient-py
Configure the library with your sdk key:
import ldclient
Get the client:
ldclient.set_sdk_key("your sdk key")
client = ldclient.get()
Create a new feature flag on your dashboard
In your application code, use the feature's key to check whether the flag is on for each user:
if client.variation("your.flag.key", {"key": "user@test.com"}, False):
# application code to show the feature
else:
# the code to run if the feature is off
Python 2.6 is supported for polling mode only and requires an extra dependency. Here's how to set it up:
Use the python2.6 extra in your requirements.txt: ldclient-py[python2.6]
Due to Python 2.6's lack of SNI support, LaunchDarkly's streaming flag updates are not available. Set the stream=False option in the client config to disable it. You'll still receive flag updates, but via a polling mechanism with efficient caching. Here's an example: config = ldclient.Config(stream=False, sdk_key="SDK_KEY")
Twisted is supported for LDD mode only. To run in Twisted/LDD mode,
Use this dependency:
ldclient-py[twisted]>=3.0.1
Configure the client:
feature_store = TwistedRedisFeatureStore(url='YOUR_REDIS_URL', redis_prefix="ldd-restwrapper", expiration=0)
ldclient.config.feature_store = feature_store
ldclient.config = ldclient.Config(
use_ldd=use_ldd,
event_consumer_class=TwistedEventConsumer,
)
ldclient.sdk_key = 'YOUR_SDK_KEY'
Get the client:
client = ldclient.get()
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.
We run integration tests for all our SDKs using a centralized test harness. This approach gives us the ability to test for consistency across SDKs, as well as test networking behavior in a long-running application. These tests cover each method in the SDK, and verify that event sending, flag evaluation, stream reconnection, and other aspects of the SDK all behave correctly.
The Code Climate coverage does not include the coverage provided by this integration test harness.
See CONTRIBUTING for more information.
| Back | FazBrowse Home | New Git URL |