Advertisement
roman_gemini

Context

Jan 21st, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. class Some:
  2.     def __enter__(self):
  3.         print("Entering context")
  4.         return self
  5.     def __exit__(self, type, value, traceback):
  6.         print("Exiting context")
  7.     def foo(self):
  8.         print("Foo!!!!")
  9.  
  10.  
  11. with Some() as s:
  12.     print("Hello, World!")
  13.     s.foo()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement