Python: How to Processe “return multiple values”

def load_datasets():

    train_file = r'D:\CNMU\AI\1X\datasets\train_catvnoncat.h5'
    test_file = r'D:\CNMU\AI\1X\datasets\test_catvnoncat.h5'

    train_datasets = h5py.File(train_file,'r')
    # train_datasets.keys()
    # <KeysViewHDF5 ['list_classes', 'train_set_x', 'train_set_y']>
    train_set_x = np.array(train_datasets['train_set_x'])
    train_set_y = np.array(train_datasets['train_set_y'])
    
    
    test_datasets = h5py.File(test_file,'r')
    test_set_x = np.array(test_datasets['test_set_x'])
    test_set_y = np.array(test_datasets['test_set_y'])
    
    classes = np.array(test_datasets['list_classes'])
    
    train_set_y = train_set_y.reshape(1,train_set_x.shape[0])
    test_set_y = test_set_y.reshape(1,test_set_x.shape[0])
    
    return train_set_x,train_set_y,test_set_x,test_set_y,classes

Here, return returns five arrays and a tuple of five elements;

train_set_x,train_set_y,test_set_x,test_set_y,classes = load_datasets()

With this assignment, you can call each array directly

Read More: