Issue31194
Created on 2017-08-13 16:12 by bup, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Messages (4) | |||
|---|---|---|---|
| msg300222 - (view) | Author: Dan Snider (bup) * | Date: 2017-08-13 16:12 | |
With the new C implementation of collections.OrderedDict, its repr correctly uses the subclass's name, unlike deque and defaultdict.
class Thing(_collections.OrderedDict):
pass
>>> Thing()
Thing([])
class Thing(_collections.deque):
pass
>>> Thing()
deque([])
|
|||
| msg300272 - (view) | Author: Raymond Hettinger (rhettinger) * ![]() |
Date: 2017-08-15 01:03 | |
IIRC, deque() did this to better match the behavior of list(). Not everything in Python is consistent and sometimes we have to pick and choose between what we want to be consistent with. For the most part, the decisions have worked out well in practice (deque.__repr__ hasn't seemed to bother anyone in its dozen year history). |
|||
| msg300297 - (view) | Author: Vedran Čačić (veky) * | Date: 2017-08-15 14:50 | |
More and more, Python looks to me like a certain language that I thought I had left behind a long time ago.
[...] Each operator decides which sort of scalar it
would be most appropriate to return.
[...] In general, they do what you want,
unless you want consistency.
Maybe it's just a sign of growing up. :-)
|
|||
| msg300298 - (view) | Author: R. David Murray (r.david.murray) * ![]() |
Date: 2017-08-15 14:54 | |
This is a duplicate of issue 27541. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:50 | admin | set | github: 75377 |
| 2017-08-15 14:54:52 | r.david.murray | set | status: open -> closed superseder: Repr of collection's subclasses nosy:
+ r.david.murray |
| 2017-08-15 14:50:14 | veky | set | nosy:
+ veky messages: + msg300297 |
| 2017-08-15 01:03:28 | rhettinger | set | messages: + msg300272 |
| 2017-08-15 00:58:54 | rhettinger | set | priority: normal -> low assignee: rhettinger versions: + Python 3.7, - Python 3.6 |
| 2017-08-13 16:55:29 | serhiy.storchaka | set | nosy:
+ rhettinger, serhiy.storchaka |
| 2017-08-13 16:12:55 | bup | create | |
