suggestions, comments on an "is_subdict" test

Vlastimil Brom vlastimil.brom at gmail.com
Fri Apr 22 16:31:15 EDT 2011


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

Thanks for all the comments!
  regards,
    vbr



More information about the Python-list mailing list