Skip to content

Instantly share code, notes, and snippets.

@RobSpectre
Last active December 2, 2024 17:11
Show Gist options
  • Save RobSpectre/99fb46ff18955d5a0b3b8e73f7cf4e52 to your computer and use it in GitHub Desktop.
Save RobSpectre/99fb46ff18955d5a0b3b8e73f7cf4e52 to your computer and use it in GitHub Desktop.
import ldclient
from ldclient.config import Config
from ldclient import Context
ldclient.set_config(Config('sdk-copy-your-sdk-key-here'))
client = ldclient.get()
if __name__ == "__main__":
alice = Context.builder('user-id-123abc1').kind('user').name('Alice').set('email', '[email protected]').build()
flag_value = client.variation("my-first-feature-flag", alice, False)
print(f"Alice's flag: {flag_value}")
bob = Context.builder('user-id-123abc2').kind('user').name('Bob').set('email', '[email protected]').build()
flag_value = client.variation("my-first-feature-flag", bob, False)
print(f"Bob's flag: {flag_value}")
carlos = Context.builder('user-id-123abc3').kind('beta-tester').name('Carlos').set('email', '[email protected]').build()
flag_value = client.variation("my-first-feature-flag", carlos, False)
print(f"Carlo's flag: {flag_value}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment