Why can custom types be keys? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

Why can custom types be keys?

Objects for dict keys are supposed to be immutable and can not contain mutable elements. Yet you can define a class and take the class itself as a key, although you could add or delete attributes at runtime. What's the logic behind this?

26th Mar 2019, 2:26 PM
HonFu
HonFu - avatar
1 Réponse
+ 5
https://wiki.python.org/moin/DictionaryKeys
26th Mar 2019, 2:59 PM
Mert Yazıcı
Mert Yazıcı - avatar