Skip to content

Instantly share code, notes, and snippets.

@bmispelon
Created May 15, 2012 07:34
Show Gist options
  • Select an option

  • Save bmispelon/2699770 to your computer and use it in GitHub Desktop.

Select an option

Save bmispelon/2699770 to your computer and use it in GitHub Desktop.
Playing around with context managers leaking into the global namespace
from contextlib import contextmanager
@contextmanager
def hacketyhack(val):
yield val
class Foo(object):
bar = 42
with hacketyhack(43) as Foo.bar:
pass
print Foo().bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment