self.file_1 = file_1
self.file_2 = file_2

def __enter__(self):
    self.fp1 = open(self.file_1[0], self.file_1[1])
self.fp2 = open(self.file_2[0], self.file_2[1])
return self.fp1, self.fp2

def __exit__(self, type, value, traceback):
    self.fp1.close()
self.fp2.close()
with open_2(('a.txt', 'w'), ('b.txt', 'w')) as fp:
    file1, file2 = fp
file1.write('aaaa')
file2.write('bbb')
Open more than 1 file using with - python