How do I change the bone layer with a script? I wanted to make a small script that loops though all the bones in the selected armature and puts the ones that match into another bone layer.

for bone in bpy.context.active_object.pose.bones[:]:
    if bone.name in ListOfBoneNames:
        #put that bone into bone layer 8


How do I put the bone onto bone layer 8? What is the function name for that?

When I do it manually, the console shows:

bpy.ops.pose.bone_layers(layers=(False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))


But I don't know how to use that in the script. Wherever I put it ("bone.bone_layers" or "bpy.context.active_object.pose.bones[bone.name].bone_layers"), it says that the object doesn't have a "bone_layers" attribute.
bone.layers is an array of 32 boolean values tells you whether the bone is present on each of the 32 layers.

So you could add the line:  bone.layer[8] = True

for bone in bpy.context.active_object.pose.bones[:]:
    if bone.name in ListOfBoneNames:
        bone.layer[8] = True  #put that bone into bone layer 8
        #could also remove the bone from other layers if you wanted!