![](https://secure.gravatar.com/avatar/60cac87fb9e2b5689242622999656cb0.jpg?s=120&d=mm&r=g)
Was thinking of all the things that could be done with Antoine's generalization: The Good ======== d = keyfuncdict(key=str.lower) # case insensitive dict def track(obj): logging.info(obj) return obj d = keyfuncdict(key=track) # monitored dict d = keyfuncdict(key=id) # makes benjamin happy The Bad ======= d = keyfuncdict(key=tuple) # lets you use lists as keys d = keyfuncdict(key=repr) # support many kinds of mutable or unhashable keys d = keyfuncdict(key=pickle.loads) # use anything picklable as a key d = keyfuncdict(key=getuser) # track one most recent entry per user The Ugly ======== d = keyfuncdict(key=random.random) # just plain weird d = keyfuncdict(key=itertools.count().next) # all entries are unique and unretrievable ;-) def remove(obj): d.pop(obj) return obj d = keyfuncdict(key=remove) # self deleting dict ;-) Raymond