To set a property you only have as a string, you can use Python's
obj = bpy.context.object
# regular method
obj.location = 1, 2, 3
# using setattr
setattr(obj, "location", (1, 2, 3))
Notice setattr takes a string, so this can come from anywhere you like.
For simple properties, this works fine, however, if you want to set a path with multiple elements this becomes more complicated.
In this case there isn't such a clean solution.
There is a blender specific function called
bpy_struct.path_resolve. Internally this uses the same method which is used to resolve FCurve and driver paths.
You could define a function for setting the attribute that combines
def value_set(obj, path, value):
if "." in path:
# gives us: ('modifiers["Subsurf"]', 'levels')
path_prop, path_attr = path.rsplit(".", 1)
# same as: prop = obj.modifiers["Subsurf"]
prop = obj.path_resolve(path_prop)
prop = obj
# single attribute such as name, location... etc
path_attr = path
# same as: prop.levels = value
setattr(prop, path_attr, value)
# example usage (requires path_resolve)
value_set(bpy.context.object, 'modifiers["Subsurf"].levels', 2)
# example usage (uses simple setattr)
value_set(bpy.context.object, 'location', (1, 2, 3))
However this is a bit involved, you could just do...
exec("obj" + path + " = value")
exec is not ideal, especially if you don't know where the inputs come from. (security considerations)
Note: even though the example uses
bpy.context.object you could use a Scene, Group, Mesh, Modifier... any Blender data really.