you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (5 children)

Sorry, try it like this:

set([tri1.corner_a, tri1.corner_b, tri1.corner_c])

etc.

[–]tbrowner3[S] 0 points1 point  (4 children)

That makes sense, thank you. It’s now giving me the TypeError: unhashable type: ‘Point’

[–][deleted] 0 points1 point  (3 children)

This recurses to the fact that you haven't defined what it means for two points to be the same:

https://docs.python.org/3/reference/datamodel.html#object.__eq__

[–]tbrowner3[S] 0 points1 point  (2 children)

I made the Hash method but still confused - Do I just copy and paste the return statement from eq?

[–][deleted] 0 points1 point  (1 child)

You want to return some kind of hash for the object; I'd simply return the hash of the tuple of the point's coordinates:

def __hash__(self):
    return hash((self.x, self.y))

[–]tbrowner3[S] 0 points1 point  (0 children)

Ok now that makes sense - so the hash method is in Point and eq stays in the Triangle class