Last active
August 29, 2015 14:08
-
-
Save rctay/e8c7f6e71b5096f257ea to your computer and use it in GitHub Desktop.
track local variables in a context
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
class LocalsTracker(object): | |
def __enter__(self): | |
self._locals = locals() | |
def __exit__(self): | |
locals_now = locals() | |
# compute diff between locals_now and self.locals... | |
def foo(): | |
a = 100 | |
with LocalsTracker(): | |
b = 10 | |
a = 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment