The LaunchDarkly SDK for Python provides functionality to integrate feature flags into your Python applications. It enables developers to control feature rollouts, perform A/B testing, and manage configurations without redeploying code. The library is actively maintained with frequent minor and patch releases, typically every 1-2 months, to introduce new features, improvements, and bug fixes.
pip install launchdarkly-server-sdkVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the LaunchDarkly client, define a user, evaluate a feature flag, and properly shut down the client. It uses an environment variable for the SDK key for security. In production, ensure the client is initialized and shut down gracefully with your application's lifecycle.
Upgrade your Python environment to 3.10 or newer. If you must use Python 3.9, pin the SDK version to `<9.15.0` (e.g., `launchdarkly-server-sdk<9.15.0`).
Upgrade your Python environment to 3.9 or newer. If you must use Python 3.8, pin the SDK version to `<9.12.0` (e.g., `launchdarkly-server-sdk<9.12.0`).
If you are using the file data source and directly manipulating `ChangeSet` objects, ensure that every change operation includes a valid `Selector` as specified in the updated API documentation.
Always use a valid LaunchDarkly SDK key. Validate your SDK key format if you encounter unexpected client initialization issues on versions 9.12.1 or newer. An SDK key usually starts with 'sdk-'
Integrate `ld_client.close()` into your application's shutdown process, for example, using a `finally` block or a signal handler in web frameworks.
Ensure the 'launchdarkly-server-sdk' package is installed in your Python environment. You can usually do this by running 'pip install launchdarkly-server-sdk'. If using a virtual environment, ensure it is activated before running your script.