Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:" ': 0.03; 'test,': 0.04; 'subject:test': 0.05; '>>>>': 0.09; 'from:addr:python': 0.09; 'wrote:': 0.14; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'mrab': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'reply-to:addr:python-list': 0.16; 'suggestions!': 0.16; 'code': 0.22; 'header:In-Reply-To:1': 0.22; 'values': 0.23; 'elegant': 0.23; 'high.': 0.23; 'keys': 0.23; 'received:84': 0.25; 'tried': 0.27; "doesn't": 0.28; 'looks': 0.28; 'thanks': 0.29; 'rid': 0.29; 'comparison': 0.31; 'however,': 0.31; 'anyone': 0.31; 'to:addr:python-list': 0.32; '(for': 0.33; 'communicate': 0.35; 'header:User-Agent:1': 0.35; 'explicit': 0.35; 'reply-to:addr:python.org': 0.35; 'but': 0.38; 'set': 0.39; 'to:addr:python.org': 0.39; 'works': 0.40; 'conversion': 0.64; 'it)': 0.68; 'reply-to:no real name:2**0': 0.72; 'header:Reply- To:1': 0.72 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjoHAITqsU1UXebj/2dsb2JhbACYGo1Md4hwvFuFdgSSNIJV Date: Fri, 22 Apr 2011 21:57:56 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 To: python-list@python.org Subject: Re: suggestions, comments on an "is_subdict" test References: <4DB190DC.8050307@mrabarnett.plus.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 19 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303505884 news.xs4all.nl 41113 [::ffff:82.94.164.166]:60338 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3894 On 22/04/2011 21:31, Vlastimil Brom wrote: > Thanks everyone for your opinions and suggestions! > I especially like the all(...) approaches of MRAB and Peter Otten, > however, the set conversion like >>>> set(test_dct.items())<= set(base_dct.items()) > True > looks elegant too. That works only if the values in the dicts are hashable. > In both approaches I can get rid of the negated comparison and the > additional "parsing cost" (for me reading it) is not that high. > > As for the name, I tried to make explicit (for this post), that both > the keys and their values are important in this test, but it doesn't > matter that much if is_subdict doesn't communicate this well > (probably?), as the "audience" of this code is not going to be anyone > but me. >