Code: Select all
>>> d={"foo":1,"bar":2,"baz":3}
>>> type(d.keys())
<class 'dict_view'>
>>> d.keys() & {'baz','foo','faz'}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported types for __and__: 'dict_view', 'set'
Code: Select all
>>> d={"foo":1,"bar":2,"baz":3}
>>> type(d.keys())
<class 'dict_keys'>
>>> d.keys() & {'baz','foo','faz'}
{'foo', 'baz'}