Re: Newbie Question - Overloading ==
- From: Amit Gupta <emailamit@xxxxxxxxx>
- Date: Mon, 31 Mar 2008 10:26:51 -0700 (PDT)
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
.
- Follow-Ups:
- Re: Newbie Question - Overloading ==
- From: xkenneth
- Re: Newbie Question - Overloading ==
- References:
- Newbie Question - Overloading ==
- From: xkenneth
- Newbie Question - Overloading ==
- Prev by Date: python scripts to standalone executable
- Next by Date: Re: Automatically fill in forms on line
- Previous by thread: Newbie Question - Overloading ==
- Next by thread: Re: Newbie Question - Overloading ==
- Index(es):