I have this script:
myObject.select = True
bpy.context.scene.objects.active = myObject
bpy.ops.object.mode_set(mode = ‘OBJECT’)
obj = bpy.data.objects
The scene has only one camera, lamp and plane in Blender 2.69.
If i run the script once nothing happends, run again and UV works. I have tested and always works after two runs. Sure must be a reason, but I’m not able to find it.