Select curve in 2.79 and 3.4.1

first trying to update a very old script

select a curve with name and print length

cu_ob = bpy.data.objects[name1].select = True

print (’ before lenght call Curve name =‘,cu_ob.name,’ cu_ob=',cu_ob )
print ()

but not working

can someone point out to make it work in 2.79 and also in BL 3.4.1
cause later on i will port it to bl 3.4.1

thanks for feedback
happy bl