block-scopes

Block scopes in Python? Whaaaaaat?!


Keywords
cursed, hack, memory, scoping, variables
License
MIT
Install
pip install block-scopes==0.2.3

Documentation

🩺 block-scopes

Block scoping in Python!

PyPI - Version PyPI - Python Version


Table of Contents

Usage

from scopes import scope

before = "I'll be kept!"

with scope("keep_me", "keep_me_too"):
    keep_me = "Keep me!"
    lose_me = "Not me!"

    keep_me_too = "Also... me!"

assert "before" in locals()
assert "keep_me" in locals()
assert "keep_me_too" in locals()

assert "lose_me" not in locals()

Installation

pip install block-scopes

License

block-scopes is distributed under the terms of the MIT license.