I have a list of objects in python that I would regularly check and destroy some of them - those which haven't been accessed lately (i.e. no method was called). 
I can maintain the last time accessed and update it in every method, but is there any more elegant way to achieve this?
Keep a dict of the IMAP connections, keyed by the user ID.  Write a function, that given a user ID, returns an IMAP connection.  The function will look up the user ID in the dict, and if the user ID is there, get the corresponding IMAP connection, and check that it's still alive.  If alive, the function returns that connection.  If not alive, or if the user ID was not in the dict, it creates a new connection, adds it to the dict, and returns the new connection.  No timestamps required.
What's the most elegant way of keeping track of the last time a python object is accessed?