3 ms·
When I read this my first thought was "you should use a FrozenDict", but looking into it, it seems that it doesn't exist; I assumed so because of FrozenSets (ha
by jotaf 7y ago
When I read this my first thought was "you should use a FrozenDict", but looking into it, it seems that it doesn't exist; I assumed so because of FrozenSets (hashable sets).
You can still create a hashable key from a dict with FrozenSet(mydict.items()).
- np_tedious 7y agoAh nice. Yes that last suggestion is probably a more simple and elegant approach than anything I'd mentioned / thought about
- typon 7y agoYou don't really need a FrozenSet if you're already willing to iterate over this dictionary. You can just use a tuple, which is also hashable. tuple(d.items())