Separating objects based on disconnected geometry ("loose parts") can be accomplished through the operator
bpy.ops.mesh.separate(type="LOOSE"). This operator attempts to separate all selected objects by loose parts. After its execution all separated objects, will be selected. If an object is initially selected, that doesn't contain loose parts, it will also be selected after the operator is finished. Therefore, you can access
bpy.context.view_layer.objects.selected and get the resulting objects.
Depending on what you intend to do with the objects, you may not want to store references to the objects in a list. If you e.g. modify the collection or view layer, these references may become invalid and accessing them could crash Blender. The safest way is to store the unique names of the objects and access them by name when needed. This is explained in the Gotcha chapter of the API docs.
TL;DR: Do not keep direct references to Blender data (of any kind)
when modifying the container of that data, and/or when some undo/redo
may happen (e.g. during modal operators execution…). Instead, use
indices (or other data always stored by value in Python, like string
keys…), that allow you to get access to the desired data.
# Separate the selected objects by disconnected geometry
# Get the selected objects
separated_obj_names = [obj.name for obj in bpy.context.view_layer.objects.selected]