Python `dict` indexed by tuple: Getting a slice of the pie
Let's say I have my_dict = { ("airport", "London"): "Heathrow", ("airport", "Tokyo"): "Narita", ("hipsters", "London"): "Soho" } What is an efficient (no scanning of all keys), yet elegant way to get all airports out of this dictionary, i.e. expected output ["Heathrow", "Narita"] . In databases that can index by tuples, it's usually possible to do something like airports = my_dict.get(("airport",*)) (but usually only with the 'stars' sitting at the rightmost places in the tuple since the index usually is only stored in one order). Since I imagine Python to index dictionary with tuple keys in a