I have written a custom mapping class that inherits from collections.Mapping
. Is there an easy way to test if an instance's data is equal to another mapping object, e.g. dict
?
Asked
Active
Viewed 339 times
1

Jason Sundram
- 12,225
- 19
- 71
- 86

Gary van der Merwe
- 9,134
- 3
- 49
- 80
1 Answers
1
Sure. Write __eq__
and __ne__
methods that perform this comparison.

kindall
- 178,883
- 35
- 278
- 309
-
I was hoping there are generic implementation of such methods for mappings that can be reused. – Gary van der Merwe Mar 28 '12 at 15:50
-
If you derive from `dict` you get comparisons to `dict` for free, but I assumed there was some reason you didn't do that. – kindall Mar 28 '12 at 16:46