Cylinder to Cone via shape key.
Here is a take on this using shape keys, Can't use 0 as the radius on the cone tip as it will not be able to be joined as shapes.
import bpy
context = bpy.context
scene = context.scene
# no active object
scene.objects.active = None
R1 = 4
R2 = 4
L = 10
# create cone
bpy.ops.mesh.primitive_cone_add(vertices=16,
radius1=R1,
radius2=R2,
depth=L)
cone1 = scene.objects.active
# create opposite cone
bpy.ops.mesh.primitive_cone_add(vertices=16,
radius1=0.001, # can't use 0
radius2=R2,
depth=L)
cone1.select = True
# join as shapes
bpy.ops.object.join_shapes()
# remove cone1
scene.objects.unlink(cone1)
bpy.data.objects.remove(cone1)
Change the R1, R2 for the second cone to suit your needs. Altering the shapekey value will give cone at 0.0, and cylinder at 1.0
context.object.data.shape_keys.key_blocks['Cone.001'].value = 1.0