Name | uplevel JSON |
Version |
0.0.4
JSON |
| download |
home_page | None |
Summary | Access the value of a variable in a higher stack frame |
upload_time | 2024-10-10 17:26:35 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | GPL3 |
keywords |
variable
stack frame
closure
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Uplevel
Access the values of variables in the parent scope. This package provides two commands: `upvar` and `uplift`.
## Installation
```bash
pip install uplevel
```
## Usage
Here is a short example of how to use `upvar` command:
```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))
```
Here is another example for the `uplift` command:
```python
import re
from uplevel import uplift
def simplematch(regex, string):
results = re.match(regex, string)
uplift(1, 'match', results)
return results
if simplematch(r"[abc]+", "abc123"):
print(f"Matched: {match.group(0)}")
```
Raw data
{
"_id": null,
"home_page": null,
"name": "uplevel",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "variable, stack frame, closure",
"author": null,
"author_email": "Michael Hohenstein <michael@hohenste.in>",
"download_url": "https://files.pythonhosted.org/packages/69/3c/bc8a97405b37aeef08986f2e91ed83f1128b0f08e37f2e4f97a6cd726785/uplevel-0.0.4.tar.gz",
"platform": null,
"description": "# Uplevel\n\nAccess the values of variables in the parent scope. This package provides two commands: `upvar` and `uplift`.\n\n## Installation\n\n```bash\npip install uplevel\n```\n\n## Usage\n\nHere is a short example of how to use `upvar` command:\n\n```python\nfrom uplevel import upvar\n\ndef fib(stop: int, step: int = 0):\n if step < 2:\n result = 0 if step == 0 else 1\n elif step <= stop:\n previous = upvar(1, 'result') # result from previous iteration\n preprevious = upvar(2, 'result') # and one iteration before\n result = previous + preprevious\n else:\n return upvar(1, 'result')\n return fib(stop, step + 1)\n\nprint(fib(20))\n```\n\nHere is another example for the `uplift` command:\n\n```python\nimport re\nfrom uplevel import uplift\n\n\ndef simplematch(regex, string):\n results = re.match(regex, string)\n uplift(1, 'match', results)\n return results\n\n\nif simplematch(r\"[abc]+\", \"abc123\"):\n print(f\"Matched: {match.group(0)}\")\n```\n",
"bugtrack_url": null,
"license": "GPL3",
"summary": "Access the value of a variable in a higher stack frame",
"version": "0.0.4",
"project_urls": {
"Repository": "https://github.com/MitchiLaser/uplevel"
},
"split_keywords": [
"variable",
" stack frame",
" closure"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fef3f156538e7bafec328fe747d51c491e96db8404ae84b2f4e3ce6d54be0f4e",
"md5": "8d0c5b8445042638059406c3cf801a79",
"sha256": "feef1c9c1a55f92caf8681c5a39efb5ca1e7e1a0304c1e337472504d86bb5417"
},
"downloads": -1,
"filename": "uplevel-0.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8d0c5b8445042638059406c3cf801a79",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 2037,
"upload_time": "2024-10-10T17:26:34",
"upload_time_iso_8601": "2024-10-10T17:26:34.782334Z",
"url": "https://files.pythonhosted.org/packages/fe/f3/f156538e7bafec328fe747d51c491e96db8404ae84b2f4e3ce6d54be0f4e/uplevel-0.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "693cbc8a97405b37aeef08986f2e91ed83f1128b0f08e37f2e4f97a6cd726785",
"md5": "f39a802c01467fffea0f0b7639780472",
"sha256": "e1c1f2ba43e5e063c676e3720d2145b4a449b04af1544842e8f3b0f88fe922db"
},
"downloads": -1,
"filename": "uplevel-0.0.4.tar.gz",
"has_sig": false,
"md5_digest": "f39a802c01467fffea0f0b7639780472",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 2108,
"upload_time": "2024-10-10T17:26:35",
"upload_time_iso_8601": "2024-10-10T17:26:35.708141Z",
"url": "https://files.pythonhosted.org/packages/69/3c/bc8a97405b37aeef08986f2e91ed83f1128b0f08e37f2e4f97a6cd726785/uplevel-0.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-10 17:26:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "MitchiLaser",
"github_project": "uplevel",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "uplevel"
}