Feature FlagsΒΆ
Runtime-configurable feature flags.
Define flags in code either in a code block:
if feature_flags.get("MY-FLAG"):
pass
or as an A/B switch:
instance = feature_flags.a_or_b("MY-FLAG", option_a="foo", option_b="bar")
Tip
option_a and option_b parameters can also be callables.
or by using as a decorator:
@feature_flags.if_enabled("MY-FLAG", default=True)
def my_feature(arg):
pass
Define flags in the applications default_settings:
FEATURE_FLAGS = {
"MY-FLAG": True,
"OTHER-FLAG": False,
}
The flag can then be enabled/disabled in the environment:
PYAPP_FLAG_MY_FLAG = yes
PYAPP_FLAG_OTHER_FLAG = off
Note
The flag name is translated into upper-case with underscores
Or from the command line:
my_app --enable-flag MY-FLAG --disable-flag OTHER-FLAG