Metadata-Version: 2.1
Name: uplevel
Version: 0.0.2
Summary: Access the value of a variable in a higher stack frame
Author-email: Michael Hohenstein <michael@hohenste.in>
License: GPL3
Project-URL: Repository, https://github.com/MitchiLaser/uplevel
Keywords: variable,stack frame,closure
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Provides-Extra: dev
Requires-Dist: black; extra == "dev"
Requires-Dist: isort; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"

# Uplevel

Access the values of variables in the parent scope.

## Installation

```bash
pip install uplevel
```

## Usage

Here is a short example of how to use `uplevel`:

```python
from uplevel import upvar

def fib(stop: int, step: int = 0):
    if step < 2:
        result = 0 if step == 0 else 1
    elif step <= stop:
        previous = upvar(1, 'result')  # result from previous iteration
        preprevious = upvar(2, 'result')  # and one iteration before
        result = previous + preprevious
    else:
        return upvar(1, 'result')
    return fib(stop, step + 1)

print(fib(20))
```
