On Oct 1, 10:35 pm, Jason Scheirer <[EMAIL PROTECTED]> wrote: > On Oct 1, 10:01 pm, Dan Barbus <[EMAIL PROTECTED]> wrote: > > > On Oct 2, 7:54 am, Dan Barbus <[EMAIL PROTECTED]> wrote: > > > > def getItemById(id): > > > return _itemsById[id] > > > I just saw that this won't compile. Still, ignoring this, I thing the > > purpose of the code is pretty clear. > > > Thanks for any feedback. > > Check the weakref module, you can create a WeakValueDictionary which > will not increment the refcount of the value, and will return None > after it's been garbage collected.
Another idea: have an AbstractFactory that keeps track of instances created. When you done, delete the abstract factory, which will delete the internal index. You'll have to figure out how to pass the factory around, and when to delete it. Weakref sounds better, overall. -- http://mail.python.org/mailman/listinfo/python-list