Bmesh script.
With a single boundary edge selected in edit mode, the LHS of question images can be achieved calling bpy.ops.mesh.loop_multi_select()
directly from the python console.
>>> bpy.ops.mesh.loop_multi_select(
loop_multi_select()
bpy.ops.mesh.loop_multi_select(ring=False)
Select a loop of connected edges by connection type
>>> bpy.ops.mesh.loop_multi_select()
{'FINISHED'}

The mesh.loop_select
operator is a different kettle of fish and requires context override if called from outside the 3D view.
This is a matter of giving the context override dictionary a 3d view "area", "space_data" and "region"
However even then, with all combos of options it still did not perform as did the alt double click on my test mesh.
Use bmesh
.
IMO edit mode mesh operators can become mind-numbingly annoying to code when they cannot be "made to perform" as desired
Touched on some other reasons to avoid operators Element indices messed up after switching from Edit to Object Mode
Can instead create our own methods
The boundary select function below takes an edge, tags it, looks at all untagged boundary edges linked to its two end verts, tags them and so on until it can go no further, then returns the edges.
Test script, run in edit mode with a single boundary edge selected.
import bpy
import bmesh
from collections import defaultdict
context = bpy.context
ob = context.edit_object
me = ob.data
bm = bmesh.from_edit_mesh(me)
edge = bm.select_history.active
assert isinstance(edge, bmesh.types.BMEdge), "Select an Edge"
def boundary_select(edge):
tag = defaultdict(bool)
tag[edge] = True
grow = True
edges = [edge]
while grow:
more = [
el for es in edges
for v in es.verts
for el in v.link_edges if not tag[el] and el.is_boundary
]
edges.extend(more)
for e in more:
tag[e] = True
grow = bool(more)
return edges
for e in boundary_select(edge):
e.select_set(True)
bmesh.update_edit_mesh(me)
3.2 Update
Context overrides are deprecated in Blender 3.2 and are scheduled to be removed in Blender 3.3 The replacement is temp_override
. The manual has examples of how to use the new function.
Persistence of element tag and select using bound bmesh
How to detect disconnected parts within a selection?