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


Groups > comp.lang.python > #3894 > unrolled thread

Re: suggestions, comments on an "is_subdict" test

Started byMRAB <python@mrabarnett.plus.com>
First post2011-04-22 21:57 +0100
Last post2011-04-22 21:57 +0100
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.


Contents

  Re: suggestions, comments on an "is_subdict" test MRAB <python@mrabarnett.plus.com> - 2011-04-22 21:57 +0100

#3894 — Re: suggestions, comments on an "is_subdict" test

FromMRAB <python@mrabarnett.plus.com>
Date2011-04-22 21:57 +0100
SubjectRe: suggestions, comments on an "is_subdict" test
Message-ID<mailman.766.1303505884.9059.python-list@python.org>
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.
>

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web