3 ms·
This bugged me, too. You can have a dictionary which maps to strings, you can have a list containing sets of frozensets of ints, but you can’t have a dictionar
by nickysielicki 5y ago
This bugged me, too.
You can have a dictionary which maps to strings, you can have a list containing sets of frozensets of ints, but you can’t have a dictionary of unhashable types.
- mturmon 5y agoYep, here's how it plays out: Python 3.8.5 (default, Sep 4 2020, 02:22:02) [Clang 10.0.0 ] :: Anaconda, Inc. on darwin >>> d=dict() >>> l=[1,2,3] >>> d[l]=42 Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unhashable type: 'list'
- setr 5y agohttps://pypi.org/project/forbiddenfruit/ https://pypi.org/project/forbiddenfruit/ Apparently there are ways to monkey patch core types, so you could probably add a __hash__ method to list…