How to get position coordinates of object moving along path at each frame?

I have a path and an object moving along this path.

I have a loop that positions the object along the path from frame 0 to frame 100.

At each frame I want to retrieve the current object world position.

I am using bpy.context.scene.update().

But it does not really update (I always just get old coordinates).

Even if I just go to one single frame, it does not update and I do not get the latest position:

bpy.data.scenes[‘Scene’].frame_current = 20
bpy.context.scene.update()
loc = bpy.context.object.matrix_world.to_translation()
loc

But loc is still an old position.
Any help?

Interestingly, when I put the Object in Edit mode,
then slide the timeline, I can watch how the “median transformation” of the selected object mesh is displayed/updated in the panel all the time, meaning it is constantly updated during the movement.

But how can I access the “median transformation” of the selected mesh through python?

I found the solution:

Using bpy.context.scene.frame_set(myframe) will update everything.
So even when using this inside a loop (moving object along path), I can always access current updated location coordinates of the moving object.