How to gracefully rewrite _ _ eq__

Magic methods

class myclass:
     def __eq__(self, other):

he rewrites all the = =, actions.
and what I want is to use this _ _ eq__
only when compared with their peers. How to implement

gracefully?
-sharp,
 def __eq__(self, other):
        if type(other)==type(self):
            return self.value==other.value
        else:
            super(SBTNode, self).__eq__(other)
Aug.11,2021

I don't know the more concise


else can be omitted; super is missing return .

Menu