Scripting equivalent to expression language property( ) function?

Working on some python scripting and trying to reference different session property values dynamically. In expression language I can just use the property( ) function and plug in whatever I want to an otherwise static path. What's the most efficient way to accomplish this in scripting?

ex. I want to access

self.session.custom.themePaths.lightMode.state.on

but I want to be able to change parts of that path. In expression language something like

property('self.session.custom.themePaths.'+{view.custom.theme}+'Mode.'+{view.custom.state})

where I can plug in any theme and state value to reference different properties. What's the easiest way in a script?

Perspective object type properties get a wrapper that makes them behave like a python dict, and the associated methods are available.

self.session[dynamicKeyA][dynamicKeyB]

or

intermediateValue = self.session.get(dynamicKeyA, fallbackA)
finalValue = intermediateValue.get(dynamicKeyB, fallbackB)

A direct 1-to-1 would be self.session.custom.themePaths[self.view.custom.theme + "Mode"][self.view.custom.state]

You can also achieve this, in the general sense, in Python via the getattr builtin:
getattr(someObjectRef, "someAttribute") == someObjectRef.someAttribute

But for Perspective objects in particular I'd use the dictionary approach Ryan mentioned directly.