In article <[EMAIL PROTECTED]>, Wildemar Wildenburger <[EMAIL PROTECTED]> wrote:
> ... how? > > I'm writing an app that holds a public data dictionary from which other > objects obtain part of their __dict__ values so they all work on the > same dataset (yes I'm fiendishly clever and a constructor of unreadable > sentences (and code) ;)). > > My problem is that I haven't found an easy way to determine if said > dictionary contents are still in use (so it is ok to delete them from > the dictionary). I've thought about creating a dict subclass that counts > the number of assignments and deletions but that seems cumbersome (an > bug-prone). > > Is there a way to get the reference count of these datadict items? I > imagine that this would be a more stable implementation of such a feature. > > Hope this gets my problem accross; if not just bash me and I'll > reformulate. I'm not the best of explainers. > > Oh, and sorry if the solution to my problem is obvious (such as an > __refcount__ attribute or some stupid oversight like that). Direct answer: sys.getrefcount() Better answer: look at the weakref module, especially at the various Dict helper classes. Just -- http://mail.python.org/mailman/listinfo/python-list