Newbie question on blender function return values

Hey Blender Artists, blender newbie here with a newbie question. If this is in the wrong place I apologize. I’m looking to duplicate a bone in a chain. At the bottom of my post is the code in context, but my questions are as follows:


test = bpy.ops.armature.duplicate()
print ("duplicated", test)

The return value in the variable test is a set containing a string saying ‘FINISHED’.
>>>duplicated {‘FINISHED’}

Is there a way to get the newly duplicated bones as a return value?
Am I doing something wrong to make blender return this set?

Help me BlenderArtists.org, you’re my only hope.

Full code in context, if it helps:

    ob = bpy.context.object

    if ob.type == 'ARMATURE':
        armature = ob.data
    bpy.ops.object.mode_set(mode='EDIT')
    for bone in armature.edit_bones:
        print (bone)
    #Get the selection
    print ("armature:", armature)
    active_joints = bpy.context.selected_bones


    for each in active_joints:
        print("active bone:", each)


    # define the start and end_joint
    start_joint = active_joints[0]
    end_joint = active_joints[-1]
    start_children = start_joint.children
    end_children = end_joint.children
    for each in start_children:
        print("start children:", each)
    for obj in bpy.data.objects:
        obj.select = False
    start_joint.select = False
    end_joint.select = True
    for each in bpy.context.selected_bones:
        print("now current active bone:", each)
    test = bpy.ops.armature.duplicate()
    print ("duplicated", test)

Output in the console:


<bpy_struct, EditBone("hip_jnt")>
<bpy_struct, EditBone("spine_jnt")>
<bpy_struct, EditBone("neck_jnt")>
<bpy_struct, EditBone("head_jnt")>
<bpy_struct, EditBone("shoulder_jnt")>
<bpy_struct, EditBone("bicep_jnt")>
<bpy_struct, EditBone("elbow_jnt")>
<bpy_struct, EditBone("forearm_jnt")>
<bpy_struct, EditBone("palm_jnt")>
<bpy_struct, EditBone("finger_jnt")>
<bpy_struct, EditBone("thumb_a_jnt")>
<bpy_struct, EditBone("thumb_b_jnt")>
<bpy_struct, EditBone("thumb_c_jnt")>
armature: <bpy_struct, Armature("Armature.001")>
active bone: <bpy_struct, EditBone("shoulder_jnt")>
active bone: <bpy_struct, EditBone("forearm_jnt")>
start children: <bpy_struct, EditBone("bicep_jnt")>
now current active bone: <bpy_struct, EditBone("forearm_jnt")>
duplicated {'FINISHED'}
current <bpy_struct, EditBone("bicep_jnt")>

Operators return strings in Blender, however the newly created object after duplication will become the active object so it’s bpy.context.object after duplication.

Sorry for not replying. Thanks for the quick answer!