Link a Material directly to an Object
To assign mat to the nth material slot on ob:
ob.material_slots[n].link = 'OBJECT'
ob.material_slots[n].material = mat

If you want to create new slots, I think you should do that on the Mesh (ob.data.materials.append(None)).