WeakValueDictionary
Mark Hammond
MarkH at ActiveState.com
Tue Sep 25 19:43:38 EDT 2001
Ken Seehof wrote:
> >>> sys.version
> '2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)]'
> >>> import weakref
> >>> d = weakref.WeakValueDictionary()
> >>> d['z']
> Traceback (most recent call last):
> File "<input>", line 1, in ?
> File "C:\PYTHON21\lib\weakref.py", line 35, in __getitem__
> o = self.data.get(key)()
> TypeError: object of type 'None' is not callable
>
> Shouldn't this be raising KeyError instead of TypeError?
Probably :)
While we are at it, I would like to see the ability to have a weak-ref
to None - this would allow me to remove special casing for None in the
places I have used weakrefs to date.
But-that-is-a-different-problem ly,
Mark.
More information about the Python-list
mailing list