Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Matt Wheeler Newsgroups: comp.lang.python Subject: Re: Set Operations on Dicts Date: Mon, 8 Feb 2016 13:32:36 +0000 Lines: 13 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de 15A7Ya5yZYS7DqfTON2PoQg7QblckeOyXwYbEOm0lm6Q== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.090 X-Spam-Evidence: '*H*': 0.84; '*S*': 0.02; 'python': 0.10; '12:17,': 0.16; '2016': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'header:In-Reply-To:1': 0.24; 'message- id:@mail.gmail.com': 0.27; 'received:google.com': 0.35; 'received:74.125.82': 0.35; 'express': 0.35; 'to:addr:python- list': 0.36; 'subject:: ': 0.37; 'to:addr:python.org': 0.40; 'union': 0.67; 'from:addr:m': 0.84; 'subject:Set': 0.91 X-Virus-Scanned: Debian amavisd-new at membrane.funkyhat.net X-Gm-Message-State: AG10YORJVDPsOF5h7K/f/bCcFtmM0M5tfOfQZrbPrw3ieFljo9Uyd3mSLSyJChHzhdOHXe9Eg1RbFG8wd6Ekhw== X-Received: by 10.194.71.46 with SMTP id r14mr10655337wju.99.1454938375396; Mon, 08 Feb 2016 05:32:55 -0800 (PST) In-Reply-To: X-Gmail-Original-Message-ID: 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:102669 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} -- Matt Wheeler http://funkyh.at