-
-
Save adeak/fa632e3bb223f21f8ed582cf77e09cf0 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
class CM: | |
def __enter__(self): | |
return self | |
def __exit__(self, *args): | |
print('hello world') | |
with CM() as cm: | |
import gc | |
gc.get_referrers(cm)[0].__func__.__code__ = (lambda self, *args: print('goodbye world')).__code__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment