Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
35 lines (27 sloc) 977 Bytes
#!/usr/bin/env python
# Written by: DGC
# python imports
# local imports
class Box(object):
def __init__(self, name): = name
def __enter__(self):
print("Box " + + " Opened")
return self
def __exit__(self, exception_type, exception, traceback):
all_none = all(
arg is None for arg in [exception_type, exception, traceback]
if (not all_none):
print("Exception: \"%s\" raised." %(str(exception)))
print("Box Closed")
return all_none
if (__name__ == "__main__"):
with Box("tupperware") as simple_box:
print("Nothing in " +
with Box("Pandora's") as pandoras_box:
raise Exception("All the evils in the world")