class Book: def __init__(self, title, author): self.title = title self.author = author def __eq__(self, other: object) -> bool: return self.title == other.title and self.author == other.author def __hash__(self) -> int: return hash((self.title, self.author)) already_read = set() already_read.add(Book("1984", "George Orwell")) book = Book("1984", "George Orwell") book2 = Book("1984", "George Orwell") already_read.add(book2) print(book in already_read) print(already_read) print(book == book2) print(book is book2) # already_read2 = set() # already_read2.add("1984") # book = "1984" # print(book in already_read2)