Created
September 3, 2018 19:43
-
-
Save im-n1/8a606fb5cedf59e8966ca4489976582d to your computer and use it in GitHub Desktop.
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
from contextlib import contextmanager | |
class X(object): | |
@contextmanager | |
def y(self): | |
print("before") | |
x = 1 | |
yield x | |
print("after") | |
x = X() | |
with x.y() as variable: | |
print(variable) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment