Why are dictionary objects unhashable in Python?

0 votes
Hi all, quick question. As per the title, I wanted to know why we cannot put in any key of our choice of a dictionary type as a dictionary (dict)?

Does it mean that there is absolutely no way to have a dictionary with a key referring to another dictionary?

All help appreciated!
Feb 8 in Python by Anirudh
• 2,070 points
19 views

1 answer to this question.

0 votes

Hi, it is not possible to hash a dictionary.

You might be wondering why. It is because they are actually mutable containers of data and it is as simple as that. 

So if the dictionary was hashed, then the contents of the hash table would vary/change along with the change in content respectively which doesn't make any sense with respect to data usage.

Hope this helped!

answered Feb 8 by Nymeria
• 3,520 points

Related Questions In Python

0 votes
2 answers

What are the types of dictionary in python?

There are 4 types of dictionary Empty Integer Mixed Dictionary with ...READ MORE

answered Feb 14 in Python by Shashank
• 1,350 points
48 views
0 votes
1 answer

What are first class objects in Python?

First-class objects in a language are handled uniformly ...READ MORE

answered Aug 2 in Python by Arvind
• 2,760 points
7 views
0 votes
1 answer

what are "and" and "or" operators in Python?

AND - True if both the operands ...READ MORE

answered Apr 17, 2018 in Python by Johnathon
• 9,070 points
41 views
0 votes
1 answer

Deleting a dictionary entry in Python

Use pop(): mapping.pop("key_x") #key_x is a key entry Note ...READ MORE

answered May 2, 2018 in Python by Nietzsche's daemon
• 4,260 points
42 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 174 views
+4 votes
6 answers
0 votes
1 answer

Pycharm warning: Must implement all abstract methods in Python. Why?

n vote As expected, python itself recognises that ...READ MORE

answered Nov 9, 2018 in Python by Nymeria
• 3,520 points
371 views
0 votes
1 answer

How to get all related Django model objects in Python?

This actually gives you the property names ...READ MORE

answered Nov 14, 2018 in Python by Nymeria
• 3,520 points

edited Dec 18, 2018 by Nymeria 500 views