WeakValueDictionary

Bryan belred1 at yahoo.com
Sun Oct 3 05:49:09 CEST 2004


there must be something i don't understand about WeakKeyDictionary and WeakValueDictionary.  i had expected the last 
line to be empty because i thought i deleted the last strong reference to variable "a". what am i misunderstanding?

 >>> d = weakref.WeakValueDictionary()
 >>> a = A()
 >>> d[1] = a
 >>> d.items()
[(1, <__main__.A instance at 0x0116BC60>)]
 >>> del a
 >>> d.items()
[(1, <__main__.A instance at 0x0116BC60>)]
 >>>

thanks,

bryan



More information about the Python-list mailing list