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, 2019 in Python by Anirudh
• 2,090 points
622 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, 2019 by Nymeria
• 3,560 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, 2019 in Python by Shashank
• 1,370 points
936 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, 2019 in Python by Arvind
• 3,050 points
3,118 views
0 votes
1 answer

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

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

answered Apr 18, 2018 in Python by Johnathon
• 9,090 points
811 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
734 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,356 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,924 views
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,560 points
3,815 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,560 points

edited Dec 18, 2018 by Nymeria 6,777 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP