How to assign a random color to objects and make them parent to specific objects using Python?
you can change the color with a simple random in r - g -b
and in order to assign each lipid_name as child of lipid_region you should use some loop... check this after run the script:



import bpy
import random

scene = bpy.context.scene

for selected_obj in scene.objects:
    selected_obj.select = False

Lipid_names = ['DGDG','DGTS','MGDG','PE','PI','SQDG','PG']
Lipid_regions = ['Lipid_DGDG','Lipid_DGTS','Lipid_MGDG','Lipid_PE','Lipid_PI','Lipid_SQDG','Lipid_PG']



for object in bpy.context.scene.objects:
    if object.name in Lipid_names:
        #color
        r, g, b = [random.random() for i in range(3)]
        object.active_material.diffuse_color = (r, g, b)

        #parent assign
        lipid_index = Lipid_names.index(object.name)
        parent_name = Lipid_regions[lipid_index]
        object.parent = bpy.data.objects[parent_name]