Split’s Python SDK brings free, scalable feature flagging to any app, website or experience built in Python. Split helps teams control rollouts, and customer experiences, while gathering new data and insight on how their products are being engaged. With Split, teams can:
Split works across many different languages, letting developers, PMs and support teams control feature rollout from one unified view—and monitor the success of any new code. Our integrations bring rollout updates into the tools your team is already using, further opening the feature-delivery process up to your entire organization.
Split's Python SDK for Django supports two different approaches to share information across processes: in-memory cache (via uWSGI) and External cache (via Redis).
django_splitio supports both Python 2 (2.7.10 or later) and Python 3 (3.3 or later) and Django 1.8 (or later). Stable versions can be installed from PyPI using pip.
Visit our documentation to learn more about using the Split Python SDK with Django.
When running Python in multi-process mode, state is usually shared between multiple processes using a remote data store. As a result, the Python SDK with multi-process support is architected differently that the plain Python SDK. This architecture has three components:
Visit our documentation to learn more about the Split Python SDK's multi-process mode.
Split's Python SDK is very simple to integrate into your code base and is completely open source. All it really takes to get rolling with Split is initiating the SDK, then splitting your code.
First, import the SDK into your project:
pip install splitio_client==2.2.0
The instantiate the SDK and create a new Split client:
from splitio import get_factory factory = get_factory('YOUR_API_KEY') split = factory.client()
We recommend instantiating it once as a singleton and reusing it throughout your application.
Include the API key for the environment you are setting up the SDK for. The API key is available under your Organization Settings page, under the APIs tab. The API key is of type sdk**
With the SDK instantiated, it’s now time to start splitting your code base. Find a feature you’d like to split, and wrap it in the split feature flag like so:
treatment = split.get_treatment('CUSTOMER_ID', 'SPLIT_NAME') if treatment == "on": # insert code here to show on treatment elif treatment == "off": # insert code here to show off treatment else: # insert your control treatment code here
The Split Python SDK integrates seamlessly into your code; no other changes or dependencies are needed to get Split up and running.
For more advanced configurations like running multiple evaluations at once, or using attributes in the SDK, take a look at our Python SDK documentation.