Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class sx:
- def __init__(self, vl):
- self.vv = vl
- def __enter__(self):
- try:
- print("in enter")
- sleep(100)
- print(2+self.vv)
- except (Exception, KeyboardInterrupt) as exc: # WHEN this line is `except Exception as exc`, then it does not catch KeyboardInterrupt. Why? - KeyboardInterrupt is not an exception? :S
- print("innner exception")
- self.__exit__(exc)
- def __exit__(self, exc, *args):
- print("exiting")
- with sx('a'):
- print(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement