How to create a script that connects points in an animation?
import bpy
from mathutils import Vector

w = 1 # weight
cList = [Vector((0,0,0)),Vector((1,0,0)),Vector((2,0,0)),Vector((2,3,0)),Vector((0,2,1))]

curvedata = bpy.data.curves.new(name='Curve', type='CURVE')
curvedata.dimensions = '3D'

# Line thickness:
curvedata.bevel_depth = 0.05
curvedata.fill_mode = "FULL"

# Point size
point_size = 0.1

# Line colour:
line_mat = bpy.data.materials.new("Red")
line_mat.diffuse_color = (1, 0, 0)
curvedata.materials.append(line_mat)

# Point colour
point_mat = bpy.data.materials.new("Green")
point_mat.diffuse_color = (0, 1, 0)

objectdata = bpy.data.objects.new("ObjCurve", curvedata)
objectdata.location = (0,0,0) #object origin
bpy.context.scene.objects.link(objectdata)

polyline = curvedata.splines.new('POLY')
polyline.points.add(len(cList)-1)
for num in range(len(cList)):
    x, y, z = cList[num]
    polyline.points[num].co = (x, y, z, w)
    bpy.ops.mesh.primitive_uv_sphere_add(location=(x, y, z), size=0.1)
    bpy.context.object.data.materials.append(point_mat)


Base on this blog post.