'Python - add functionality to function to access information from previous call

I got a function like below:

def my_func(some_objects):
    objects_information = []
    for object_ in some_objects:
        object_information = dict()
        object_information['name'] = some_object.name
        object_information['position'] = some_object.position
        object_information['previous_position'] = previous_position or None
        objects_information.append(object_information)
    return objects_information

how can I add to that function an option to hold information about the objects position so in the line object_information['previous_position'] I can use the information object_position['position'] from the last call to the function? If object_information['name'] is the same as in previous call and if it's the first call with that object_name it will place None in previous_position key.

Thank you very much



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source