Jan-15-2020, 05:06 PM
Hi everyone.
I am trying to play with the new @dataclass and TypedDict from 3.7 and 3.8
But after searching and reading lots of documentation I cannot find a proper answer on this. I think the answer is simple but it's not clear to me.
Here the snippet:
Obviously if I replace the property with a hashable object it works.
Thank you for your help
Hobbit
I am trying to play with the new @dataclass and TypedDict from 3.7 and 3.8
But after searching and reading lots of documentation I cannot find a proper answer on this. I think the answer is simple but it's not clear to me.
Here the snippet:
from dataclasses import dataclass @dataclass(frozen=True, eq=True, repr=False) class Building: name: str property: dict foo = Building(name="Test", property={"key": 10}) var = {foo}and the error:
File "<string>", line 3, in __hash__ TypeError: unhashable type: 'dict'Ok the message is clear, but I don't understand why all nested element of a set need to be hashable. I don't find anything that tell me: a set take only hashable element that have itself hashable element
Obviously if I replace the property with a hashable object it works.
Thank you for your help
Hobbit