Set Operations on Dicts
Random832
random832 at fastmail.com
Mon Feb 8 09:52:43 EST 2016
On Mon, Feb 8, 2016, at 08:32, Matt Wheeler wrote:
> On 8 February 2016 at 12:17, Jussi Piitulainen
> <jussi.piitulainen at helsinki.fi> 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))
More information about the Python-list
mailing list