Function decorator that ensures that no global and no nonlocal variables are used, making Jupyter notebooks much safer
Project description
no_global_nonlocal_vars
Function decorator that ensures that no global and no nonlocal variables are used, making Jupyter notebooks much safer
Installing
Install:
pip install no_global_nonlocal_vars
Usage
# Correct Output
@no_global_nonlocal_vars
def test_no_global_nonlocal_vars_GOOD(x, repeat):
return np.array([x] * repeat)
# Error from typo
@no_global_nonlocal_vars
def test_no_global_nonlocal_vars_typo_GOOD(x_typo, repeat_typo):
return np.array([x] * repeat)
# Nested function works
@no_global_nonlocal_vars
def test_no_global_nonlocal_vars_nested_GOOD(x, repeat=10):
@no_global_nonlocal_vars
def helper(x, repeat):
return np.array([x] * repeat)
return helper(x, repeat)
# Error from nonlocal variable typo
@no_global_nonlocal_vars
def test_no_global_nonlocal_vars_nested_typo_GOOD(x, repeat=10):
@no_global_nonlocal_vars
def helper(x_typo, repeat_typo):
return np.array([x] * repeat)
return helper(x, repeat)
Notes
- The errors show up only upon first time running the function, not at function definition time
Related Work
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file no_global_nonlocal_vars-0.0.1.tar.gz
.
File metadata
- Download URL: no_global_nonlocal_vars-0.0.1.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 204434df4d3b60d8ecdfece19be32ff655b6d7ca1b135d9491919b2fad7a72a3 |
|
MD5 | e921e1d66b4cf5802fe1b130e497190d |
|
BLAKE2b-256 | 43725d24807b5eedcbf595048d188660df43218c4363f277fb7083ea7a73782d |
File details
Details for the file no_global_nonlocal_vars-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: no_global_nonlocal_vars-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca01f2dd46a07f2280bc15272c0c4065f4bb029c263250d813b7cc8b5c65c434 |
|
MD5 | 56b638bdb772f739ba9e11794b05bfb3 |
|
BLAKE2b-256 | 2c320340775fd43c9f32d3b97f5f99268be9a596ff0948ed3932e6c07db81c33 |