How to spin a curve to create a surface using python script?
Screw the curve too.

Similarly to creating with bmesh



import bpy


def poly(x):
    return   0.2 * x * x - x + 3

cu = bpy.data.curves.new("poly", 'CURVE')
cu.dimensions  = '3D'
bez = cu.splines.new('BEZIER')
pts = [(poly(z), 0, z) for z in range(10)]
flat = [p for pt in pts for p in pt]
s = cu.splines.new('BEZIER')
s.bezier_points.add(len(pts) - 1)
# set the points in one fell swoop
s.bezier_points.foreach_set("co", flat)
# doesn't seem to work for handles so set them in loop
for bp in s.bezier_points:
    bp.handle_left_type = bp.handle_right_type = 'AUTO'

# lazy way to add curve object
bpy.ops.curve.primitive_bezier_curve_add()
ob = bpy.context.object
ob.data = cu

# default screw modifier spins 360 on z
screw = ob.modifiers.new("Screw", 'SCREW')