-1

I have two dicts spec_copy and actual_specs and want to compare values of these two for keys of spec_copy only. This is what I'm trying -
all(spec_copy[k] != actual_specs[k] for k in spec_copy.keys()).
Upon debugging these are the key values of those two dicts. -

enter image description here

enter image description here

Clearly the version is different still the condition returns False. It should return True instead.

bosari
  • 1,922
  • 1
  • 19
  • 38
  • Are all pairs of values different? No, they aren't, only one is different. Therefore it correctly returns `False`. I think you meant to implement the logic "are all pairs of values *equal*". – mkrieger1 Apr 03 '21 at 09:11

1 Answers1

4

I think you meant to use

any(spec_copy[k] != actual_specs[k] for k in spec_copy.keys())
joergbrech
  • 2,056
  • 1
  • 5
  • 17