Created
March 1, 2012 11:15
-
-
Save jacob414/1949138 to your computer and use it in GitHub Desktop.
Simple demo of Altered States context manager
This file contains hidden or 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
from altered import state | |
class A(object): pass | |
o = A() | |
o.foo = 'foo' | |
with(state(o, foo='bar')): | |
# prints 'bar' | |
print o.foo | |
# prints 'foo', o.foo now restored to previous value | |
print o.foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment