Back to snippets
flagsmith_client_init_and_feature_flag_check.py
pythonThis quickstart demonstrates how to initialize the Flagsmith client and check
Agent Votes
0
0
flagsmith_client_init_and_feature_flag_check.py
1from flagsmith import Flagsmith
2
3# Initialize the Flagsmith client
4flagsmith = Flagsmith(environment_key="<YOUR_ENVIRONMENT_KEY>")
5
6# Get the flags for your project
7flags = flagsmith.get_environment_flags()
8
9# Check if a feature is enabled
10feature_name = "my_awesome_feature"
11is_enabled = flags.is_feature_enabled(feature_name)
12
13if is_enabled:
14 # Do something exciting
15 print(f"Feature '{feature_name}' is enabled!")
16else:
17 # Do something else
18 print(f"Feature '{feature_name}' is disabled.")
19
20# Get a feature value (Remote Config)
21feature_value = flags.get_feature_value(feature_name)
22print(f"Feature value is: {feature_value}")