How can I access a property if I know the path?
The simple answer is that you can't get the value from a string of the entire path. You need to have a path to an object where you can use getattr() to get a value or object from that object. But it's simple to write code to bypass this and use the entire path.
Also, I am probably not using all the correct technical terms, so if someone points out what I need to change, I'll gladly fix it - or they can just edit it.
If you have the path bpy.context.scene.render.image_settings.color_mode and want to get color_mode, you cannot use:
getattr(bpy.context.scene.render.image_settings.color_mode)
But if you have the path to the image_settings object, you can do this:
getattr(bpy.context.scene.render.image_settings, 'color_mode')
So, normally, and for getattr() you need the path to, and including, the object (in this case image_settings) and then specify the object or setting you need.
But if you have an issue where you'll have entire path names in strings (like bpy.context.scene.render.image_settings.color_mode), for whatever reason, it's possible to simply step through each level to get to the item you need. Here's how I did it:
import bpy

cm = &quot;bpy.context.scene.render.image_settings.color_mode&quot;
cd = &quot;bpy.context.scene.render.image_settings.color_depth&quot;

path = cd

#
#start with splitting the string into all the different nodes
nodes = path.split('.')

#
#loop through all the nodes in order
for node in nodes:
    #If it's the first node, bpy, we have to start differently
    #than wth the others - so set the object to bpy
    if node == 'bpy':
        obj = bpy
        continue
    #We have a node, so now get the next one
    obj = getattr(obj, node)
#Print out the final node we've gotten to - note that now the
#object (obj) is not a node, but the value stored in that node
print(&quot;Last level: %s, type: %s&quot; % (obj, type(obj)))

I used the path to two different settings, color_mode and color_depth as examples and you can easily change which one you're testing in the 4th line of code (not counting blank lines).
Just split the entire path at periods, so you'll get a list with each level of the path in it, in order. Then step through each one (note it's a bit different on the first one). At each level, you use the current object to get the object at the next level down. When you reach the end, you'll have the object (whether it's just an object, or a string or setting value) that you need.
The output for this is just:
Last level: 8, type: &lt;class 'str'&gt;
Taking this and turning it into something you can call so it returns the object you're looking for is trivial. Just pass the entire path to the function and it returns the object.
This does not include any error trapping and assumes you're starting at bpy, so if you want to be able to start at context (since that's often easily available), you'll need to work in how to handle a string starting with that level.