[issue26973] Dict View binops permit non-set types
Joshua Morton
report at bugs.python.org
Sun May 8 03:08:07 EDT 2016
Joshua Morton added the comment:
There (seemed to be) consensus between the one or two on topic commenters that something was off, although much of the discussion was on a tangent. Although on looking back, there was even less discussion than I originally thought. Heh.
My response was going to be very different, however I did some additional digging: the `collections.abc.Set` class can be used as a mixin for implementing set-likes. In its default implementations of the various binops, they will attempt to convert the right hand argument of an operator to the correct type, via _from_iterable. This in effect makes the set the special case that is more permissive than Set is.
This strikes me as strange, I'd expect set and Set to be 'the same', or in other words a Set to act like a set and vice versa. But it seems that python swings toward your intuition and not mine. And the opposite, making set *more* permissive also doesn't sit well, nor does it feel necessary.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26973>
_______________________________________
More information about the Python-bugs-list
mailing list