Selecting a point of a curve in edit mode to make a translation operation

Hello
My script is not working like I want :-). I have a curve with several points. Now I want to select the endpoint and make a translation. The code:

curve = bpy.data.curves.new(self.Name+varName, type='CURVE')
                curve.dimensions = '3D'
                curve.resolution_u = 1
                spline = curve.splines.new('NURBS')
                .....


                # End
                spline.points.add()
                spline.points[-1].co = (x*xscale, 0.0,0.0,1)
                
                curveObject = bpy.data.objects.new(self.Name+varName, curve)
                bpy.context.scene.objects.link(curveObject)
                
                bpy.context.scene.objects.active = curveObject
                bpy.ops.object.mode_set(mode='EDIT', toggle=False)            
               
                spline.points[-1].select = True
               
                bpy.ops.transform.translate(value=(0, 0, -0.8), constraint_axis=(False, False, True), constraint_orientation='GLOBAL', mirror=False, proportional='ENABLED', proportional_edit_falloff='SMOOTH', proportional_size=1, release_confirm=True, use_accurate=False)
                
                bpy.ops.object.mode_set(mode='OBJECT', toggle=False)        

but nothing happens, when I run it (also no error). What made I wrong in my code?
Thank you very much for helping to resolve my problem.

Hello

I found the problem :yes:.
Insted of:


spline.points[-1].select = True

it should be:


curveObject.data.splines.active.points[-1].select = True

and like this it works fine.