Skip to main content

make_hashable

Attempt to make value hashable or raise a TypeError if it fails.

The returned value should generate the same hash for equal values.

def make_hashable(
value: Any
) - > Any

Attempt to make value hashable or raise a TypeError if it fails. The returned value should generate the same hash for equal values.

Parameters

NameTypeDescription
valueAnyThe object to be converted into a hashable format, such as a dictionary, list, or other nested collection.

Returns

TypeDescription
AnyA hashable version of the input value, typically converted to a sorted tuple of pairs for dictionaries or a tuple for other iterables.