Re: Newbie Question - Overloading ==



On Mar 31, 10:23 am, xkenneth <xkenn...@xxxxxxxxx> wrote:

class A:
def __eq__(self,other):
return self.a == other.a and self.b == other.b

class B:
def __eq__(self,other):
return self.a == other.a and self.c == other.c


Thanks!

Regards,
Kenneth Miller

Can't say aboyt unpythonic: I am no expert at that: but to avoid
catching Attribute-Error everywhere, you can redefine __eq__ as
def __eq__(self, other) :
try :
return <>
except AttributeError:
return False
.