Created
January 21, 2014 16:30
-
-
Save weissjeffm/8543311 to your computer and use it in GitHub Desktop.
contextmgr example
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 Provider(object): | |
def __init__(self, x=None): | |
self.x = x | |
myprov = Provider(x=0) | |
with update(myprov) as updated: | |
updated.x = 1 | |
updated.x | |
# 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment