Accessing Drivers - Can't Get to 'Expression' from Object to update dependencies

I am trying to access my drivers dependencies programmatically while referring to this post:


But there is no explanation of how they got to the point of :

driver.expression += " "
driver.expression = driver.expression[:-1]

So I have tried looking through these posts to help me but was unable to get anything going:





https://docs.blender.org/api/blender_python_api_2_78_release/bpy.types.Driver.html

None of which helped. Here is a picture up my setup:

I am at a total loss, and don’t see how I can access the name of the variable to change it in order to update it programmatically, one line returned such:

>>> print(bpy.data.objects["02-ZL250FT"].animation_data.drivers[0].expression)
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
AttributeError: 'FCurve' object has no attribute 'expression'

So what am I missing, where have I gone wrong?

Looks like the “drivers” are actually functions or methods of F-curves, so “driver[0].driver” is the way to get to that point, which I was unable to find stated anywhere.

>>> print(bpy.data.objects["02-ZL250FT"].animation_data.drivers[0].driver.expression)
var