[issue45780] dict. keys view behavious diverges from set()

2021-11-10 Thread Gregory P. Smith


New submission from Gregory P. Smith :

Python 3.9.7 (default, Sep 24 2021, 09:43:00) 
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> dict(a=3,b=5).keys()
dict_keys(['a', 'b'])
>>> dict(a=3,b=5).keys() - 'a'
{'b'}
>>> dict(a=3,b=5).keys() - 'ab'
set()
>>> set(('a', 'b'))
{'b', 'a'}
>>> set(('a', 'b')) - 'ab'
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unsupported operand type(s) for -: 'set' and 'str'
>>> set(('a', 'b')).difference('ab')
set()

basically it looks like the keys view treats - as .difference() whereas set() 
avoids bugs in its operators by requiring both to be sets.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45780] dict. keys view behavious diverges from set()

2021-11-10 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
components: Interpreter Core
nosy: gregory.p.smith
priority: normal
severity: normal
stage: needs patch
status: open
title: dict. keys view behavious diverges from set()
type: behavior
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com