the.bay.news

Adding objects to set or dictionary: equality and hashing

programming.dev
Adding objects to set or dictionary: equality and hashing
Yesterday my exercise [https://programming.dev/post/54997527] got downvoted, probably because its point was unclear. I’d like to try again with this reworked exercise. Hope you’ll like this one better. - Solution [https://memory-graph.com/#codeurl=https%3A%2F%2Fraw.githubusercontent.com%2Fbterwijn%2Fmemory_graph_videos%2Frefs%2Fheads%2Fmain%2Fexercises%2Fother2.py&play=] - Explanation [https://docs.python.org/3/reference/datamodel.html#object.__hash__]: “User-defined classes have __eq__() and __hash__() methods by default (inherited from the object class); with them, all objects compare unequal (except with themselves) and x.__hash__() returns an appropriate value such that x == y implies both that x is y and hash(x) == hash(y).” #Python #memory_graph #Equality #Hashing

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.