This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients rhettinger, serhiy.storchaka, xiang.zhang
Date 2016-07-17.08:54:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1468745676.7.0.929499219743.issue27541@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2016-07-17 08:54:36serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, xiang.zhang
2016-07-17 08:54:36serhiy.storchakasetmessageid: <1468745676.7.0.929499219743.issue27541@psf.upfronthosting.co.za>
2016-07-17 08:54:36serhiy.storchakalinkissue27541 messages
2016-07-17 08:54:36serhiy.storchakacreate