To control the Bind of the Surface Deform Modifier with Python

I’m going to write a script that adds Surface Deform Modifier to multiple objects in batches and binds it to the target object.

I succeeded in adding a Modifier to all selected objects and setting a target object, but failed to bind. Currently, my script runs Bind operation only for the active object.

How can I fix my script?

import bpy

obs             = bpy.context.selected_objects
modifier_type   = 'SURFACE_DEFORM'
modifier_target = bpy.data.objects['Plane']

for ob in obs :
    ob.modifiers.new(name=modifier_type,type=modifier_type)
    ob.modifiers[modifier_type].target=modifier_target
    bpy.ops.object.surfacedeform_bind(modifier=modifier_type)

Need to select and make each object active first. Operators like the apply modifier(and looks like this one) only works on active object.

I added a statement about object activation and now it works as intended. Thank you.

import bpy

obs             = bpy.context.selected_objects
modifier_type   = 'SURFACE_DEFORM'
modifier_target = bpy.data.objects['Plane']

for ob in obs :
    # set modifier
    ob.modifiers.new(name=modifier_type,type=modifier_type)
    ob.modifiers[modifier_type].target=modifier_target
    
    # binding
    bpy.context.view_layer.objects.active = bpy.data.objects[ob.name]
    bpy.ops.object.surfacedeform_bind(modifier=modifier_type)