Set Operations on Dicts

Grobu snailcoder at retrosite.invalid
Tue Feb 9 02:21:22 EST 2016


On 08/02/16 17:12, Ian Kelly wrote:

> dict does already expose set-like views. How about:
>
> {k: d[k] for k in d.keys() & s}  # d & s
> {k: d[k] for k in d.keys() - s}  # d - s
>
Interesting. But seemingly only applies to Python 3.


More information about the Python-list mailing list