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


Groups > comp.lang.python > #3877

Re: suggestions, comments on an "is_subdict" test

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <wolfgang@rohdewald.de>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:" ': 0.03; 'subject:test': 0.05; 'dictionary': 0.07; 'received:localnet': 0.07; 'wrote:': 0.14; 'from:addr:rohdewald.de': 0.16; 'from:addr:wolfgang': 0.16; 'from:name:wolfgang rohdewald': 0.16; 'message-id:@rohdewald.de': 0.16; 'received:91.62': 0.16; 'received:rohdewald.de': 0.16; 'reply-to:addr:rohdewald.de': 0.16; 'reply-to:addr:wolfgang': 0.16; 'wolfgang': 0.16; 'cc:2**0': 0.20; 'code': 0.22; 'header:In-Reply-To:1': 0.22; 'keys': 0.23; 'value.': 0.25; 'equivalent': 0.26; 'cc:addr:gmail.com': 0.31; 'received:mo-p00-ob.rzone.de': 0.31; 'does': 0.31; 'to:addr :python-list': 0.32; 'presence': 0.33; 'reference': 0.34; 'clearly': 0.34; 'header:User-Agent:1': 0.35; 'charset:us-ascii': 0.36; 'should': 0.37; 'to:addr:python.org': 0.39; 'received:de': 0.39; 'would': 0.40; 'header:Message-Id:1': 0.62; 'reply-to:no real name:2**0': 0.72; 'header:Reply-To:1': 0.72
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; t=1303483437; l=485; s=domk; d=rohdewald.de; h=Content-Transfer-Encoding:Content-Type:MIME-Version:In-Reply-To: References:Cc:Date:Subject:To:Reply-To:From:X-RZG-CLASS-ID:X-RZG-AUTH; bh=TN2hf3fqtE8O9K3EA38LrlShMtc=; b=mvDTVUMrSBnWA0fvjtW4Tc7NbmI6QZFO2w9F9qAInp0+KSWTMZUTTCh3UZQ4ZgTCT99 Ufjtgbhknx71SyF/GYSH5Dnvkgbxvi5Ar94wcx3h7o3L4xWGo5V3dofM2TbdivYV3yDwb cNsa6GSdMkA0o4uFBiWsAiBvsL7EKRiij7s=
X-RZG-AUTH :O2MIc0epdfgAjoV+frHI3UhxNCLBO5P+YS73lHhJYRD2uAuzaM+5N8MTpOrjKBI=
X-RZG-CLASS-ID mo00
From Wolfgang Rohdewald <wolfgang@rohdewald.de>
To python-list@python.org
Subject Re: suggestions, comments on an "is_subdict" test
Date Fri, 22 Apr 2011 16:43:54 +0200
User-Agent KMail/1.13.5 (Linux/2.6.35-28-generic; KDE/4.6.2; x86_64; ; )
References <BANLkTinazu41uVqxmkfTns0ZOHScZ1a3nQ@mail.gmail.com>
In-Reply-To <BANLkTinazu41uVqxmkfTns0ZOHScZ1a3nQ@mail.gmail.com>
MIME-Version 1.0
Content-Type Text/Plain; charset="us-ascii"
Content-Transfer-Encoding 7bit
X-Spam-Status No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY shortcircuit=no autolearn=ham version=3.3.1
X-Spam-Checker-Version SpamAssassin 3.3.1 (2010-03-16) on i5
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To wolfgang@rohdewald.de
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.752.1303483438.9059.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 82.94.164.166
X-Trace 1303483438 news.xs4all.nl 41113 [::ffff:82.94.164.166]:34765
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:3877

Show key headers only | View raw


On Freitag 22 April 2011, Vlastimil Brom wrote:
> check whether all items of a given dictionary are
> present in a reference dictionary

I would not call this is_subdict. That name does not
clearly express that all keys need to have the same
value.

set(subdict.items()) <= set(reference.items())

should be equivalent to your code

if you only want to check for presence of all
keys in the reference dict:

set(subdict.keys()) <= set(reference.keys())

-- 
Wolfgang

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


Thread

Re: suggestions, comments on an "is_subdict" test Wolfgang Rohdewald <wolfgang@rohdewald.de> - 2011-04-22 16:43 +0200

csiph-web