Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!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: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:" ': 0.03; 'subject:test': 0.05; 'dictionary': 0.07; 'def': 0.13; 'this?': 0.18; 'code': 0.22; 'header:In-Reply-To:1': 0.22; 'received:209.85.220': 0.26; 'message-id:@mail.gmail.com': 0.28; 'testing': 0.28; 'to:addr:python-list': 0.32; 'reference': 0.34; 'received:209.85': 0.37; 'received:google.com': 0.38; 'anything': 0.38; 'comments': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'i.e.': 0.40; 'header:Received:5': 0.40; 'simple': 0.60 MIME-Version: 1.0 Sender: z@etiol.net X-Originating-IP: [200.107.244.177] In-Reply-To: <4DB190DC.8050307@mrabarnett.plus.com> References: <4DB190DC.8050307@mrabarnett.plus.com> Date: Fri, 22 Apr 2011 10:43:05 -0400 X-Google-Sender-Auth: pYtdp-vOYMVqUianJTdALzK6TW0 Subject: Re: suggestions, comments on an "is_subdict" test From: Zero Piraeus To: python-list@python.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list 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: 13 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303483390 news.xs4all.nl 81485 [::ffff:82.94.164.166]:34269 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3876 : >> I'd like to ask for comments or advice on a simple code for testing a >> "subdict", i.e. check whether all items of a given dictionary are >> present in a reference dictionary. Anything wrong with this? def is_subdict(test_dct, base_dct): return test_dct <= base_dct and all(test_dct[k] == base_dct[k] for k in test_dct) -[]z.