[New-bugs-announce] [issue28278] Make `weakref.WeakKeyDictionary.__repr__` meaningful

Ram Rachum report at bugs.python.org
Mon Sep 26 12:28:49 EDT 2016


New submission from Ram Rachum:

Both `WeakKeyDictionary` and `WeakValueDictionary` have opaque `__repr__` methods:

>>> x = weakref.WeakKeyDictionary({object: 2, type: 4,})
>>> x
<WeakKeyDictionary at 0x32e6198>
>>> dict(x)
{<class 'type'>: 4, <class 'object'>: 2}

This makes it annoying to view them at a glance. Is there a reason for it? (I don't know, maybe because they're weakref? Though I'm not sure how that would affect this decision.)

If there isn't a reason, then maybe there should be a nice `__repr__` that lets you see the objects inside?

----------
components: Library (Lib)
messages: 277431
nosy: cool-RR
priority: normal
severity: normal
status: open
title: Make `weakref.WeakKeyDictionary.__repr__` meaningful
type: enhancement
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28278>
_______________________________________


More information about the New-bugs-announce mailing list