save location vector of an object
The print statement worked fine for me. My approach would be to collect the positions in a list and iterate at the last frame over the list to determine the length. 

import bpy
from mathutils import *
from math import *

test = Vector((0,0,0))
locations = [] # list to hold all locations between start and end frame

def my_handler(scene):
    if scene.frame_current == scene.frame_start:
        locations.clear()
    if scene.frame_current == scene.frame_end:
        total_len = 0
        for i in range(len(locations)-1):
            d = locations[i] - locations[i+1]
            total_len += d.length
        print("length %f" % total_len )

    location = bpy.data.objects['cube1'].location
    locations.append(Vector(location))
    #print(location)
    #print(locations)

bpy.app.handlers.frame_change_post.clear()
bpy.app.handlers.frame_change_post.append(my_handler)