[Python-ideas] Dictionary views are not entirely 'set like'
Michael Selik
mike at selik.org
Thu Apr 7 13:53:40 EDT 2016
> On Apr 6, 2016, at 10:38 AM, Joshua Morton <joshua.morton13 at gmail.com> wrote:
> set() | [] # 2
> {}.keys() | [] # 3
Looks like this should be standardized. Either both raise TypeError, or both return a set. My preference would be TypeError, but that might be worse for backwards-compatibility.
> {}.keys().union(set()) # 6
Seems to me that the pipe operator is staying on MappingView, so it's reasonable to add a corresponding ``.union`` to mimic sets. And intersection, etc.
> {}.values() == {}.values() # 9
> d = {}; d.values() == d.values() # 10
It's weird, but float('nan') != float('nan'). I'm not particularly bothered by this.
More information about the Python-ideas
mailing list