How do I adjust bone rotation_mode when freshly created armature has pose = None (python) I am creating a lot of armatures using python.  One of the things I need to do is set the rotation_mode on all the bones to be 'XYZ' instead of 'QUATERNION'.

Unfortunately the following (super-trimmed-down) code malfunctions:

import bpy

scn = bpy.context.scene
obj = bpy.data.objects.new('garbage', bpy.data.armatures['lids_armature.007'])
scn.objects.link(obj)

obj.pose.bones[0].rotation_mode = 'XYZ'


It gives me the following error:

Traceback (most recent call last):
  File "/home/thoth/art/mehndi/mehndi.blend/garbage", line 7, in &lt;module&gt;
AttributeError: 'NoneType' object has no attribute 'bones'
Error: Python script fail, look in the console for now...


What is the proper python technique for setting the bones' rotation_mode immediately after creation?
LucaRood in IRC was the first one to suggest using scn.update() after the link().  batFINGER and my testing agree with that solution.  So the proper code would be

import bpy

scn = bpy.context.scene
obj = bpy.data.objects.new('garbage', bpy.data.armatures['lids_armature.007'])
scn.objects.link(obj)

scn.update()
obj.pose.bones[0].rotation_mode = 'XYZ'