how to find the data_path for scripted keyframes I would like to script keyframes for bevel modifier width (and many more later). Here is what I have so far. I've commented out the last line which doesn't work. When I type help(ao.keyframe_insert), I get :arg data_path: path to the property to key, analogous to the fcurve's data path. but that doesn't help me since I haven't use fcurves yet.

The first half of my question is "how to key the bevel width as I am trying in the example script?" 

...and the second half is "where could I have looked this up?" or "how can I know in general what do write in keyframe_insert(data_path="" without asking a new question each time I want to key something?"

Thanks for your understanding!

import bpy
import numpy as np

frame_a, frame_b = 25, 35
sigma_a, sigma_b = 7, 10
n_frames = 60

if 1 == 1:
    bpy.ops.mesh.primitive_cube_add(radius=1, location=(0.0, 0.0, 2.0))
    bpy.ops.object.modifier_add(type='BEVEL')
    bpy.context.object.modifiers["Bevel"].width = 0.3
    bpy.context.object.modifiers["Bevel"].segments = 3

ao = bpy.context.active_object

bpy.context.scene.frame_end = n_frames

for i_frame in range(n_frames):
    a = np.exp(-(i_frame - frame_a)**2 / (2.*sigma_a**2))
    s = 1.0 + 0.3 * a
    bw = 1.0 * a
    ao.modifiers["Bevel"].width = bw
    ao.scale = (s, s, s)
    ao.keyframe_insert(data_path="scale", frame = i_frame + 1, index=-1)
    #ao.keyframe_insert(data_path="modifiers['Bevel'].width", frame = i_frame + 1, index=-1)
To get the data_path of a UI element (property, icon..), rightclick it and select "Copy Data Path"



Wrapping the resulting data_path with double quotes is a legal python string representation (eg: "modifiers['Bevel'].width"), and arguably should be allowed. But the parser of properties favours 'modifiers["Bevel"].width', presumably to keep the string parsing to a  minimal implementation.



The above will be able to compute most kinds of data_path, but if it fails you can   


make a keyframe for the property
go to the Outliner (set to view Datablocks)
navigate to Actions -> (Object/Scenename)+Action -> F-Curve
See Data Path. (this is what the initial 


  path to the property to key, analogous to the fcurve's data path


refers to.)