I tried below code and it works perfectly.
import h5py
class H5Loader():

    def __init__(self):
        self.hdf5_files = ['A.hdf5', 'B.hdf5']
        self.data_lst = []
        for ind in self.hdf5_files:
            h5_file = h5py.File(ind)
            data_ = h5_file.get('data')
            self.data_lst.append(data_)
            h5_file.close()


if __name__=="__main__":

    hdfDummy = H5Loader()