suggestions, comments on an "is_subdict" test

Zero Piraeus schesis at gmail.com
Fri Apr 22 11:19:52 EDT 2011


:

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

Really? That was what ``test_dct <= base_dct and`` ... is supposed to
prevent. Have I missed something?

 -[]z.



More information about the Python-list mailing list