Last active
September 19, 2021 21:28
-
-
Save mpettis/7c897c14588f0fe256c68faee7227552 to your computer and use it in GitHub Desktop.
Local variable scoping in Python. Keeps from polluting namespaces.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://pypi.org/project/scoping/ | |
# See also: https://github.com/bskinn/tempvars | |
from scoping import scoping | |
aofl = [{"a":1, "b":2}, {"a":3, "b":4}] | |
with scoping(): | |
for d in aofl: | |
x = d | |
scoping.keep('x') | |
print(d) | |
print(x) | |
print('d' in dir()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment