[Armature Scripting] How do I find out PoseBone's posed head and tail location?

I have armature A that I want to edit the bones in a script such that all the bones in armature A matches up with amature B’s posed location.

My current code is

edit_bone = rig_A.data.edit_bones.get(bone_name_a)
pose_bone = rig_B.pose.bones.get(bone_name_b)

edit_bone.head.x = pose_bone.head.x
edit_bone.head.y = pose_bone.head.y
edit_bone.head.z = pose_bone.head.z

edit_bone.tail.x = pose_bone.tail.x
edit_bone.tail.y = pose_bone.tail.y
edit_bone.tail.z = pose_bone.tail.z

However this only moves the edit bones to B’s rest position rather than posed position. Is there anyway to get posed location of pose_bone’s head and tail?

Is there any reason why you can’t set the armature’s pose position mode to pose, then back to relative after operations are done?

bpy.data.armatures["Armature"].pose_position = "POSE"
bpy.data.armatures["Armature"].pose_position = "REST" 

OMG, thank you!!! that worked. If you ask why I can’t because I didn’t know that’s a thing :smiling_face_with_tear:.