Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/willcrichton/context-var

React-style context variables (i.e. dynamic scoping)
https://github.com/willcrichton/context-var

Last synced: 23 days ago
JSON representation

React-style context variables (i.e. dynamic scoping)

Awesome Lists containing this project

README

        

# context-var

[![Build Status](https://travis-ci.com/willcrichton/context-var.svg?branch=master)](https://travis-ci.com/willcrichton/context-var)
[![PyPI version](https://badge.fury.io/py/context-var.svg)](https://badge.fury.io/py/context-var)

React-style context management, i.e. dynamically scoped variables. Example:

```python
import context_var as cv

var = cv.ContextVar('hello')
assert var.get() == 'hello'

with var.set('world'):
assert var.get() == 'world'

assert var.get() == 'hello'
```

## Installation

```python
pip install context-var
```