Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #102728

Re: Set Operations on Dicts

From Ian Kelly <ian.g.kelly@gmail.com>
Newsgroups comp.lang.python
Subject Re: Set Operations on Dicts
Date 2016-02-09 08:14 -0700
Message-ID <mailman.10.1455030904.29838.python-list@python.org> (permalink)
References <mailman.86.1454925476.2317.python-list@python.org> <n9a2jk$9s$1@dont-email.me> <mailman.106.1454948013.2317.python-list@python.org> <n9c3rd$1vt$1@dont-email.me>

Show all headers | View raw


On Tue, Feb 9, 2016 at 12:21 AM, Grobu <snailcoder@retrosite.invalid> wrote:
> 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.

Substitute d.viewkeys() for d.keys() in Python 2.7.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Set Operations on Dicts Marco Kaulea <marco.kaulea@gmail.com> - 2016-02-08 10:56 +0100
  Re: Set Operations on Dicts Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-02-08 14:17 +0200
    Re: Set Operations on Dicts Marco Kaulea <marco.kaulea@gmail.com> - 2016-02-08 13:33 +0100
    Re: Set Operations on Dicts Matt Wheeler <m@funkyhat.org> - 2016-02-08 13:32 +0000
      Re: Set Operations on Dicts Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-02-08 16:02 +0200
    Re: Set Operations on Dicts Random832 <random832@fastmail.com> - 2016-02-08 09:52 -0500
      Re: Set Operations on Dicts Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-02-08 17:05 +0200
  Re: Set Operations on Dicts Grobu <snailcoder@retrosite.invalid> - 2016-02-08 13:47 +0100
    Re: Set Operations on Dicts Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-08 09:12 -0700
      Re: Set Operations on Dicts Grobu <snailcoder@retrosite.invalid> - 2016-02-09 08:21 +0100
        Re: Set Operations on Dicts Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-09 08:14 -0700

csiph-web