Python
Installation
Install the tggl
package:
Quick start
Start by creating a client using your API key and use it to evaluate contexts:
You can then check flag results:
A single API call evaluating all flags is performed when calling
eval_context
,
making all subsequent flag checking methods extremely fast.
This means that you do not need to cache results of is_active
and get
since
they do not trigger an API call, they simply look up the data in the already fetched response.
is_active
vs get
By design, you have no way of telling apart an inactive flag, a non-existing flag, a deleted flag, or a network error. This design choice prevents anything from breaking your app by just deleting a flag, messing up the API key rotation, or any other unforeseen event, it will simply consider any flag to be inactive.
Do not use get
if you simply want to know if a flag is active or not, use is_active
instead.
get
gives you the value of an active flag, and this value may be "falsy" (None, False, 0, or empty string), leading to unexpected behaviors: