Replace cube with sphere with a python script

Hi,

How to replace a mesh cube with a mesh sphere in a python script.

bpy.ops.mesh.primitive_cube_add(radius=1,location=(0, 0, 0))
ob = bpy.context.object
cube=bpy.context.object
bpy.ops.mesh.primitive_uv_sphere_add(size=1, location=(1.66798, 1.62977, -1.74158))
sphere = bpy.context.object

cube.link(sphere)

you should replace the data of the object.
cube.data = sphere.data