Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #3880 > unrolled thread
| Started by | Peter Otten <__peter__@web.de> |
|---|---|
| First post | 2011-04-22 17:06 +0200 |
| Last post | 2011-04-22 17:06 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: suggestions, comments on an "is_subdict" test Peter Otten <__peter__@web.de> - 2011-04-22 17:06 +0200
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2011-04-22 17:06 +0200 |
| Subject | Re: suggestions, comments on an "is_subdict" test |
| Message-ID | <mailman.753.1303484755.9059.python-list@python.org> |
Zero Piraeus wrote: > : > >>> 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) It may raise a KeyError.
Back to top | Article view | comp.lang.python
csiph-web