Skip to content

Instantly share code, notes, and snippets.

@RobSpectre
Created December 2, 2024 16:46
Show Gist options
  • Save RobSpectre/592e933bbc35ea445b752cd3deef794d to your computer and use it in GitHub Desktop.
Save RobSpectre/592e933bbc35ea445b752cd3deef794d to your computer and use it in GitHub Desktop.
quickstart.py
import ldclient
from ldclient.config import Config
from ldclient import Context
ldclient.set_config(Config('sdk-copy-your-key-here'))
client = ldclient.get()
if __name__ == "__main__":
if client.is_initialized():
print("LaunchDarkly is successfully authenticated to your account.")
else:
print("There was an issue authenticating - is the SDK key correct?")
context = Context.builder('user-id-123abc').kind('user').name('Sandy').set('email', '[email protected]').build()
flag_value = client.variation("my-first-feature-flag", context, False)
print(f"Our first feature flag is: {flag_value}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment