[issue26973] Dict View binops permit non-set types

2016-05-08 Thread Joshua Morton

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 <rep...@bugs.python.org>
<http://bugs.python.org/issue26973>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26973] Dict View binops permit non-set types

2016-05-07 Thread Joshua Morton

New submission from Joshua Morton:

Following the comments in python ideas [1], I'm submitting a bug report. In 
python 3, dictionary views (KeysView and ItemsView specifically) do not adhere 
to the same interface as Sets. Specifically, the __and__, __or__, __xor__, and 
__sub__ methods on Views will accept a non-set type (`{}.keys() | []`), while 
the same throws a TypeError on a Set. The suggested, not-backwards-compatible 
solution, was to have dictviews raise errors in the same way. 

[1] https://mail.python.org/pipermail/python-ideas/2016-April/039469.html

--
messages: 265110
nosy: Joshua Morton
priority: normal
severity: normal
status: open
title: Dict View binops permit non-set types
type: behavior
versions: Python 3.4, Python 3.5

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26973>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com