classification
Title: OrderedDict KeysView set operations not supported
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: out of date
Dependencies: Superseder: set() operators don't work with collections.Set instances
View: 8743
Assigned To: Nosy List: Matthew.Lauria, rhettinger, serhiy.storchaka
Priority: normal Keywords:

Created on 2014-05-31 15:51 by Matthew.Lauria, last changed 2014-05-31 16:04 by serhiy.storchaka. This issue is now closed.

Messages (2)
msg219454 - (view) Author: Matthew Lauria (Matthew.Lauria) Date: 2014-05-31 15:51
I noticed that doing set operations on an OrderedDict KeysView only works when the KeysView is the first input to the expression, and not when it's the second input. This is not the case for dicts.

Python 3.4.1 (default, May 31 2014, 11:25:02) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import collections
>>> x = collections.OrderedDict()
>>> x.keys() - set()
set()
>>> set() - x.keys()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for -: 'set' and 'KeysView'

>>> y = {}
>>> y.keys() - set()
set()
>>> set() - y.keys()
set()
msg219456 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-05-31 16:04
Already fixed in issue8743.
History
Date User Action Args
2014-05-31 16:04:05serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg219456

superseder: set() operators don't work with collections.Set instances
resolution: out of date
2014-05-31 15:51:12Matthew.Lauriacreate