Random object color via python
Yep, you are assigning all new random colours to the first object.

def get_random_color():
    ''' generate rgb using a list comprehension '''
    r, g, b = [random.random() for i in range(3)]
    return r, g, b, 1


then in the loop, once you create the object you get a reference to it.
somethng like:

obj = bpy.ops.mesh.primitive_cube_add()
obj.color = get_random_color()


This way you will call a function to get random rgba on every new object