Is there a way to assign vertex groups to all loose elements via python
Another take on this. Already had code that separated a mesh into vertex groups from seams, 

import bpy

def island_verts(mesh):  
    import bmesh
    bpy.ops.object.mode_set(mode='EDIT')
    bpy.ops.mesh.select_all(action='DESELECT')

    bm = bmesh.from_edit_mesh(mesh)
    bm.verts.ensure_lookup_table()
    verts = [v.index for v in bm.verts]

    vgs = []
    while len(verts):        
        bm.verts[verts[0]].select = True
        #bpy.ops.mesh.select_linked(delimit={'SEAM'})
        bpy.ops.mesh.select_linked()
        sv = [v.index for v in bm.verts if v.select]
        vgs.append(sv)
        for v in sv:
            bm.verts[v].select = False
            verts.remove(v)
    bm.free() # prob not nec.        
    bpy.ops.object.mode_set(mode='OBJECT')
    return vgs      

# test run            
obj = bpy.context.object
mesh = obj.data
vgs = island_verts(mesh)

for vg in vgs:
    group = obj.vertex_groups.new()
    group.name = "Island"
    group.add(vg, 1.0, 'ADD')