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


Groups > comp.lang.python > #102675

Re: Set Operations on Dicts

From Jussi Piitulainen <jussi.piitulainen@helsinki.fi>
Newsgroups comp.lang.python
Subject Re: Set Operations on Dicts
Date 2016-02-08 17:05 +0200
Organization A noiseless patient Spider
Message-ID <lf57fif1bu3.fsf@ling.helsinki.fi> (permalink)
References <mailman.86.1454925476.2317.python-list@python.org> <lf5fux3xuov.fsf@ling.helsinki.fi> <CAG93HwH72zLDm-fnnzAuKUSqTqPF3YesX_m5pE8YHQUqbAe+xA@mail.gmail.com> <mailman.98.1454943165.2317.python-list@python.org>

Show all headers | View raw


Random832 writes:

> On Mon, Feb 8, 2016, at 08:32, Matt Wheeler wrote:
>> On 8 February 2016 at 12:17, Jussi Piitulainen wrote:
>> > Also, what would be the nicest current way to express a priority union
>> > of dicts?
>> >
>> > { k:(d if k in d else e)[k] for k in d.keys() | e.keys() }
>> 
>> Since Python 3.5: {**e, **d}
>
> And before that... dict(ChainMap(d, e))

New in version 3.3. Thanks, I didn't know of that either. Reading the
docs, I think for the use I had in mind, ChainMap(d, e) itself would
suffice.

Back to comp.lang.python | Previous | NextPrevious in thread | Next 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