Help unbind all materials from selected object
Try this, it affects all selected objects.
import bpy
for ob in bpy.context.selected_objects:
    for ms in ob.material_slots:
        if ms.material and ms.material.users &gt; 1:
            ms.material = ms.material.copy()

Note that it may not do what you expect if an object has two slots with the same material.