How to clean weight groups by script?
I did come up with a solution, but probably not the most elegant one. The vertex_group_clean method is an accessor to a menu, it is not a method to an object. So in the solution I select and activate an object, then switch to weight view, select all the vertices, do cleaning, and switch back to object view.

def active(obj):
    bpy.ops.object.select_all(action='DESELECT')
    obj.select=True
    bpy.context.scene.objects.active = obj
    bpy.ops.object.mode_set(mode = 'OBJECT')

for obj in bpy.context.visible_objects:
    if obj.name[-2:] == '-l':
        active(obj)
        bpy.ops.paint.weight_paint_toggle()
        bpy.ops.paint.vert_select_all(action="SELECT")
        bpy.ops.object.vertex_group_clean(group_select_mode='ALL', limit=0.005, keep_single=True)
        bpy.ops.paint.vert_select_all(action="DESELECT")
        bpy.ops.paint.weight_paint_toggle()


It does the job, but I hope there is a better way to write this :)