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


Groups > comp.lang.python > #3876

Re: suggestions, comments on an "is_subdict" test

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 <z@etiol.net>
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 <BANLkTinazu41uVqxmkfTns0ZOHScZ1a3nQ@mail.gmail.com> <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 <schesis@gmail.com>
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 <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.751.1303483390.9059.python-list@python.org> (permalink)
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

Show key headers only | View raw


:

>> 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.

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


Thread

Re: suggestions, comments on an "is_subdict" test Zero Piraeus <schesis@gmail.com> - 2011-04-22 10:43 -0400

csiph-web