Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Random832 Newsgroups: comp.lang.python Subject: Re: Set Operations on Dicts Date: Mon, 08 Feb 2016 09:52:43 -0500 Lines: 11 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de BTLN3naQlWn9z2WMPf98tgM9gNz3wWIN/ENRl5hAPELQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'received:internal': 0.09; 'python': 0.10; '12:17,': 0.16; '2016': 0.16; 'e))': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:io': 0.16; 'received:messagingengine.com': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'feb': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'express': 0.35; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'received:66': 0.38; 'to:addr:python.org': 0.40; 'header:Message-Id:1': 0.61; 'union': 0.67; 'subject:Set': 0.91 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=V1ZdBlMvZnNR07sV5NnFYklU3D8=; b=1Wk67B UyN1Ch1qwDNoiWAHgS2gYtSHjBm8S7eX/UndVEFoyyscuUDKQwkXVx8REBtDEDrA c29Nsf9BeMWrdcGw65xAH1y6jlfojuLmas1wiMhxFleWnzv+IasSAnQwin9g/wXN LiSLg24PxV3TRY2QwTHW1W/eEeOXLBFglBy8g= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=V1ZdBlMvZnNR07s V5NnFYklU3D8=; b=T2YXK7P1gm99gpPpVDVolgsNBfaJdf4n7OBfK8QyLRC0Kv6 ZjGQdJw/tzoK5Agy2h/XQK60MOIXmZyBQmFYhA9RT17ZFenlKMTFl0M/9RD2ZoOi M+bjJflx8ljH8N+MgJpAafy52LKGNbOXtes/Wt/Pjvayi8Bj5H+6IxfIKzXE= X-Sasl-Enc: OEZ5pD0bOyWfkh34SHbw4z0GayCZ7+X536Xzg/+8AfFR 1454943163 X-Mailer: MessagingEngine.com Webmail Interface - ajax-57359b3d In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:102673 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))