How to parent two objects in python
bpy.ops.mesh.primitive_cube_add()
a = bpy.context.object
bpy.ops.object.empty_add(type="SPHERE")
b = bpy.context.object
const = b.constraints.new(type='CHILD_OF')
const.target = a