[issue27541] Repr of collection's subclasses
Serhiy Storchaka
report at bugs.python.org
Sun Jul 17 04:54:36 EDT 2016
New submission from Serhiy Storchaka:
The repr of subclasses of some collection classes contains a name of the subclass:
>>> class S(set): pass
...
>>> S([1, 2, 3])
S({1, 2, 3})
>>> import collections
>>> class OD(collections.OrderedDict): pass
...
>>> OD({1: 2})
OD([(1, 2)])
>>> class C(collections.Counter): pass
...
>>> C('senselessness')
C({'s': 6, 'e': 4, 'n': 2, 'l': 1})
But the repr of subclasses of some collection classes contains a name of the base class:
>>> class BA(bytearray): pass
...
>>> BA([1, 2, 3])
bytearray(b'\x01\x02\x03')
>>> class D(collections.deque): pass
...
>>> D([1, 2, 3])
deque([1, 2, 3])
>>> class DD(collections.defaultdict): pass
...
>>> DD(int, {1: 2})
defaultdict(<class 'int'>, {1: 2})
Shouldn't a name of the subclass always be used?
----------
components: Extension Modules, Interpreter Core
messages: 270621
nosy: rhettinger, serhiy.storchaka, xiang.zhang
priority: normal
severity: normal
status: open
title: Repr of collection's subclasses
type: enhancement
versions: Python 3.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27541>
_______________________________________
More information about the Python-bugs-list
mailing list