I'm working on a small module for MicroPython (and Python3) and have need to override several of the special methods like __add__ etc; which all work except for __eq__.
Under MicroPython __eq__ seems to only return a single boolean rather than the specified list as it does under Python3.
Using the following test case:
Code: Select all
class eqtest:
def __init__(self, data):
self.data = data
def __eq__(self, other):
return [self.data[i] == other.data[i] for i in range(len(self.data))]
x = eqtest([1,2,3])
y = eqtest([1,2,3])
z = eqtest([1,4,3])
print('x == y =>', x == y, ' x.__eq__(y) =>', x.__eq__(y))
print('x == z =>', x == z, ' x.__eq__(z) =>', x.__eq__(z))
Code: Select all
$ python3 eq_test.py
x == y => [True, True, True] x.__eq__(y) => [True, True, True]
x == z => [True, False, True] x.__eq__(z) => [True, False, True]
Code: Select all
>>> import eq_test
x == y => False x.__eq__(y) => [True, True, True]
x == z => False x.__eq__(z) => [True, False, True]
I just wondered what the reasoning is if by design or if this is a bug (or just not implemented yet)?
Thanks,
Jamie