pyscript
pyscript copied to clipboard
using __eq__ in class doesn't seem to work
Hi,
I'm using some classes inside my pyscripts.
I stumbled across a weird behavior when trying to define the __eq__ in one of my classes.
Here's a mockup class which reproduces the issue -
class A():
def __init__(self, b):
self.b = b
def __eq__(self, other):
return self.b == other
When I init a class obj, let's say -a = A(5), I always get True when trying to compare.
So for example a == 3 gives True, a == 'cow' gives True.
Adding logging inside the __eq__ doesn't show anything so I believe that function isn't even being called.
I'm running all this on jupyter using the hass pyscript kernel Running the same on a normal python interpreter gives the expected resutls..
What am I missing here?