Python Language Tuple Tuple Are Element-wise Hashable and Equatable

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

hash( (1, 2) )  # ok
hash( ([], {"hello"})  # not ok, since lists and sets are not hashabe

Thus a tuple can be put inside a set or as a key in a dict only if each of its elements can.

{ (1, 2) } #  ok
{ ([], {"hello"}) ) # not ok


Got any Python Language Question?