# Set Bezier curve control points coordinates and rotation with python script

I'm fairly new to blender and I'm trying to create a Bézier curve via python scripting and edit the control points' global location global and rotation. Is there any way of transforming the control points the same way as with the item -> transform menu (whie in edit mode - 'G' and 'R' keboard shortcuts) ?

I tried something like this :

import bpy

bpy.ops.object.select_by_type(type='CURVE')
bpy.ops.object.delete(use_global=False)

bpy.ops.curve.de_select_first()

bpy.context.object.location.x = 1
bpy.context.object.location.y = 2
bpy.context.object.location.z = 4

bpy.ops.object.editmode_toggle()


but that only changes the curve's location. Is there any working way to use something similar to this :

bpy.context.object.data.splines[0].bezier_points[0].location.x = 1
# bpy.context.active_object.location.x = alpha - on object


or this :

bpy.context.object.data.splines[0].bezier_points[0].rotation_euler[0] = 1
# bpy.context.active_object.rotation_euler[2] = 1 - on object


specifically on the control points and not on the whole curve ?