suggestions, comments on an "is_subdict" test

Zero Piraeus schesis at gmail.com
Fri Apr 22 10:43:05 EDT 2011


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


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /