Hello I searched the whole web for good examples on weakref module's 
WeakKeyDictionary, but have found none, All I find is the Python Docs 
explanations, and some examples which actually doesn't explain how the 
mechanism of key reference removal works:

import weakref
class Tracking:
    _instances_dict = weakref.WeakValueDictionary(  )
    _num_generated = 0
    def _ _init_ _(self):
        Tracking._num_generated += 1
        Tracking._instances_dict[Tracking._num_generated] = self
    def instances(  ): return _instances_dict.values(  )
    instances = staticmethod(instances)



      

Reply via email to