Message302807
Some of these were Guido's design decisions made over a decade ago. He explicitly choose not have the spelled-out method names (both here in the concrete class and in the corresponding abstract base classes). It usually isn't a good idea to second guess his long standing decisions which have worked out well in practice.
From my own point-of-view, I prefer not to use the set curly brace notation in the repr for several reasons.
1) Ideally, the reprs for the keys(), values(), and items() should all have a similar look. The list notation is equally applicable to all of three, but the set notation isn't applicable to the values() which can have duplicates and may have non-hashable values.
2) The keys(), values(), and items() are guaranteed to be in the same order. The list notation reinforces this fact while the set notation does not.
3) There may be unforeseen usability issues (perhaps the change might falsely imply that there is an underlying set rather than a view of the dict, or perhaps it would imply that the full set() API is supported which it is not).
4) In Python 2, all three methods actually returned lists even though it would have been possible to return a set() for the keys. Though it isn't required, I do like the continuity in thought between the versions. |
|
Date |
User |
Action |
Args |
2017-09-23 21:22:05 | rhettinger | set | recipients:
+ rhettinger, bup |
2017-09-23 21:22:05 | rhettinger | set | messageid: <1506201725.67.0.955408999437.issue31563@psf.upfronthosting.co.za> |
2017-09-23 21:22:05 | rhettinger | link | issue31563 messages |
2017-09-23 21:22:05 | rhettinger | create | |
|