How to move the points of a Curve in Python while in Edit Mode
bpy.data.Curves don't currently have a secondary representation, like bpy.data.Mesh does. Meshes can be represented as a bmesh, and they can be manipulated by Python while the Mesh is in Edit Mode. Curves on the other hand (Spline, Bezier, NURBS) don't have an additional representation that lets you modify their data via script while in Edit Mode. 

A solution is to switch the Edit Mode to Object Mode, then do your manipulation, then switch back to Edit Mode if you need.

in short

bpy.ops.object.mode_set(mode='OBJECT')
for p in bpy.context.object.data.splines.active.bezier_points:
    p.co.z = 0
bpy.ops.object.mode_set(mode='EDIT')


You won't notice it switching in and out of OBJECT mode, but the bezier_points will be updated, and it will be placed back in EDIT mode.

Ideasman42 states: "changes to bpy.context.object.data are not displayed, and they will be overwritten when exiting editmode."