Surprise: del weakref.WeakKeyDictionary[ item ] raises RuntimeError

Greg Ewing (using news.cis.dfn.de) ckea25d02 at sneakemail.com
Tue Apr 8 22:56:59 EDT 2003


Mike C. Fletcher wrote:
>        for ref in self.data.iterkeys():
>            o = ref()
>            if o == key:
>                del self.data[ref]
>                return
> 
> Using keys seems to avoid the 
> problem, but with the obvious disadvantages of keys vs. iterkeys.

Maybe a separate list of keys could be maintained
alongside the dict?

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg





More information about the Python-list mailing list