I'm writing a class and want to overload the __and__ function
class Book(object):
def __init__(self, name, pages):
self.name = name
self.pages = pages
def __and__(self, other):
return '{}, {}'.format(self.name, other.name)
When I run this
Book('hamlet', 50) and Book('macbeth', 60)
I would expect to get 'hamlet, macbeth'
However, it appears the overload does nothing. What am I doing wrong?