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 <rep...@bugs.python.org>
<http://bugs.python.org/issue28278>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to