How can I assign string variables to an object selection list
Consider a pointer property.
Prior to being able to set a property to point to another object, would have used names, and some naming convention, or custom property on the object to &quot;mark it&quot;.
However since the ability to assign pointers would consider instead creating a pointer property, that when updated adds and sets the modifiers to the object accordingly.

Simple example, adds a deform_object pointer property to every object. When this is set the modifier is tested for, and created if it does not exist. If the object is set to None (unset) the modifiers are removed.
Test script. Added a test UI to text editor footer.
import bpy
from bpy.types import Object
from bpy.props import PointerProperty

def poll(self, object):
    return (
            object.type == 'MESH' 
            and self is not object
            # and ...
            )

def update(self, context):
    # modifiers
    sdm = self.modifiers.get(&quot;DynToMesh&quot;)
    if self.deform_object:
        if not sdm:
            sdm = self.modifiers.new(&quot;DynToMesh&quot;, type='SURFACE_DEFORM')
            # set some mod props when created
            sdm.strength = 1.5
        sdm.target = self.deform_object
    else:
        # clear modifiers
        if sdm:
            self.modifiers.remove(sdm)
            

bpy.types.Object.deform_object = PointerProperty(
        type=Object,
        update=update,
        poll=poll,
        )
        
def draw(self, context):
    ob = context.object
    self.layout.prop(ob, &quot;deform_object&quot;)
    
# stick draw in text editor footer to test

bpy.types.TEXT_HT_footer.prepend(draw)

Note the update will also be fired when set via code, eg the following in python console is the equivalent of setting / unsetting as shown in GIF above
&gt;&gt;&gt; C.object
bpy.data.objects['Cube']

&gt;&gt;&gt; C.object.deform_object = D.objects['Cube.001']

&gt;&gt;&gt; C.object.deform_object = None