def __init__(self, name):
    self.name = name

def __enter__(self):
    self.start = self.timer()

def __exit__(self, ty, val, tb):
    end = self.timer()
print('%s : %0.3f seconds' % (self.name, end - self.start))
return False
How do I define a Python class that I can use with the with statement?