I am looking for a way to achieve the following: A dictionary that returns the current datetime when the key is accessed. (So NOT the datetime of when the key was stored)
Example that does not do what i want:
d = {'key': datetime.datetime.now()}
d['key'] # returns datetime of dic creation instead of current
As my dictionary key will be accessed by existing code outside of my control, i am unable to do things like d['key']().
I was hoping of something similar to the @property decorator for classes, which executes a function when accessed