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.
Select a loop of connected edges by connection type
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.
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.
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"
tag = defaultdict(bool)
tag[edge] = True
grow = True
edges = [edge]
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
for e in more:
tag[e] = True
grow = bool(more)
for e in boundary_select(edge):
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?