Top "Hashable" questions

This Hashable package defines a class, Hashable, for types that can be converted to a hash value.

Why can't I use a list as a dict key in python?

I'm a bit confused about what can/can't be used as a key for a python dict. dicked = {} dicked[None] = …

python list dictionary tuples hashable
Python: how to slice a dictionary based on the values of its keys?

Say I have a dictionary built like this: d={0:1, 1:2, 2:3, 10:4, 11:5, 12:6, 100:7, 101:8, 102:9, 200:10, 201:11, 202:12} and I want to create a subdictionary d1 by slicing d …

python dictionary key slice hashable
Conforming to Hashable protocol?

I'm trying to make a dictionary with the key as a struct I've created and the value as an array …

swift struct swift3 hashable
How can I use a Swift enum as a Dictionary key? (Conforming to Equatable)

I've defined an enum to represent a selection of a "station"; stations are defined by a unique positive integer, so …

dictionary enums swift hashable
Add a dictionary to a `set()` with union

I just ran across something interesting that I thought I'd ask about. Adding a dictionary to a set, I had …

python dictionary set hashable
What makes a user-defined class unhashable?

The docs say that a class is hashable as long as it defines __hash__ method and __eq__ method. However: class …

python class python-3.x user-defined-types hashable
Check for mutability in Python?

Consider this code: a = {...} # a is an dict with arbitrary contents b = a.copy() What role does mutability play in …

python python-3.x immutability python-2.x hashable
Using @functools.lru_cache with dictionary arguments

I have a method that takes (among others) a dictionary as an argument. The method is parsing strings and the …

python dictionary python-3.x hashable
How to solve TypeError: unhashable type 'list'

I have two lists I would like to modify a particular content of the first list and send the output …

python mongodb list dictionary hashable
Make struct Hashable?

I'm trying to create a dictionary of the sort [petInfo : UIImage]() but I'm getting the error Type 'petInfo' does not …

swift dictionary swift3 hashable