Wtih XXX as yy:
Here, yy is the value returned by enter
Define the __enter__ method in the class
def __enter__(self):
....
return self
#A total of 4 parameters, the last 3 are related to exceptions, they are exception type, exception value, traced stack
def __exit__(self,exc_type,exc_val,exc_tb):