def enregister(d, obj):
    obj.ds.append(d)
d[obj.key] = obj


class Item(object):

    def __init__(self, uniq_key, title=None):
        self._key = uniq_key
self.title = title
self.ds = []

def adjust_key(self, newkey):
    newds = [d for d in self.ds if self._key in d]
for d in newds:
    del d[self._key]
d[newkey] = self
self.ds = newds
self._key = newkey

def get_key(self):
    return self._key
key = property(get_key, adjust_key)
Python data structure for a collection of objects with random access based on an attribute