A way to find if an object is a sub-object of another?
Is there an operator or built-in function in python where I can do something like the following?
>>> needle={"age": 10, "name": "peter"}
>>> haystack={"age":10, "name": "peter", "height": 100}
>>> needle & haystack == haystack
The equivalent, I suppose, of set-intersection, but now with key-value pairs.
Is there a name for this in intersection-on-maps in programming?
One roundabout way of doing this is the following:
>>> set(needle.items()) & set(haystack.items()) == set(needle.items())
True