The Full Stack Developer Guide Developer Hub

Welcome to the Full Stack Developer Guide developer hub. You'll find comprehensive guides and documentation to help you start working with the Full Stack Developer Guide as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Is Feature Enabled

Determines whether a feature is enabled for a given user. The purpose of this method is to allow you to separate the process of developing and deploying features from the decision to turn on a feature. Build your feature and deploy it to your application behind this flag, then turn the feature on or off for specific users.

Version

SDK v3.0

Description

This method traverses the client's datafile and checks the feature flag for the feature key that you specify.

This method evaluates the feature rollout for a user. The method checks whether the rollout is enabled, whether the user qualifies for the audience targeting, and then randomly assigns either on or off based on the appropriate traffic allocation. If the feature rollout is on for a qualified user, the method returns true.

Parameters

The table below lists the required and optional parameters in Python.

Parameter
Type
Description

feature_key
required

string

The key of the feature to check for access.

The feature key is defined from the Features dashboard.

user_id
required

string

The ID of the user to check for feature access.

attributes
optional

dict

A dict of custom key-value pairs specifying attributes for the user that are used for audience targeting. Non-string values are only supported in the 3.0 SDK and above.

Returns

True if the feature is enabled for the user. Otherwise, false.

Examples

This section shows a simple example of how you can use the is_feature_enabled method.

# Evaluate a feature flag
enabled = optimizely_client.is_feature_enabled('price_filter', user_id)

Source files

The language/platform source files containing the implementation for Python is optimizely.py.

Updated 2 years ago


Is Feature Enabled


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.