Re: Contains/equals

2010-08-24 Thread Hrvoje Niksic
Lawrence D'Oliveiro writes: > In message , Alex Hall > wrote: > >> def __eq__(self, obj): >> if self.a==obj.a and self.b==obj.b: return True >> return False > > Is there a “Useless Use Of ...” award category for these “if then > return True; else return False” constructs? Well, remember

Re: Contains/equals

2010-08-24 Thread Lawrence D'Oliveiro
In message , Alex Hall wrote: > def __eq__(self, obj): > if self.a==obj.a and self.b==obj.b: return True > return False Is there a “Useless Use Of ...” award category for these “if then return True; else return False” constructs? -- http://mail.python.org/mailman/listinfo/python-list

Re: Contains/equals

2010-08-19 Thread Christian Heimes
Am 19.08.2010 20:53, schrieb Tim Chase: > On 08/19/10 12:42, Steven D'Aprano wrote: >> On Thu, 19 Aug 2010 11:00:03 -0400, Alex Hall wrote: >> >>> def __eq__(self, obj): >>>if self.a==obj.a and self.b==obj.b: return True >>>return False >> >> That would be the same as: >> >> def __eq_

Re: Contains/equals

2010-08-19 Thread Tim Chase
On 08/19/10 12:42, Steven D'Aprano wrote: On Thu, 19 Aug 2010 11:00:03 -0400, Alex Hall wrote: def __eq__(self, obj): if self.a==obj.a and self.b==obj.b: return True return False That would be the same as: def __eq__(self, obj): return self.a==obj.a and self.b==obj.b Or,

Re: Contains/equals

2010-08-19 Thread Steven D'Aprano
On Thu, 19 Aug 2010 11:00:03 -0400, Alex Hall wrote: > def __eq__(self, obj): > if self.a==obj.a and self.b==obj.b: return True > return False That would be the same as: def __eq__(self, obj): return self.a==obj.a and self.b==obj.b -- Steven -- http://mail.python.org/mailman/l

Re: Contains/equals

2010-08-19 Thread Christian Heimes
Am 19.08.2010 17:00, schrieb Alex Hall: > In Python, as I understand it, you can define this behavior. > > class c(object): > def __init__(self, a=1, b=2): > self.a=a; self.b=b > > def __eq__(self, obj): > if self.a==obj.a and self.b==obj.b: return True > return False Yes, but you have t

Re: Contains/equals

2010-08-19 Thread Alex Hall
On 8/19/10, Peter Otten <__pete...@web.de> wrote: > Karsten Wutzke wrote: > >> I have an object which has a list of other complex objects. How do I >> best achieve a complex "contains" comparison based on the object's >> class? In Java terms, I'm looking for an equivalent to equals(Object) >> in Py

Re: Contains/equals

2010-08-19 Thread Karsten Wutzke
On Aug 19, 4:47 pm, Peter Otten <__pete...@web.de> wrote: > Karsten Wutzke wrote: > > I have an object which has a list of other complex objects. How do I > > best achieve a complex "contains" comparison based on the object's > > class? In Java terms, I'm looking for an equivalent to equals(Object)

Re: Contains/equals

2010-08-19 Thread Peter Otten
Karsten Wutzke wrote: > I have an object which has a list of other complex objects. How do I > best achieve a complex "contains" comparison based on the object's > class? In Java terms, I'm looking for an equivalent to equals(Object) > in Python. Does a similar thing exist? Directions appreciated.

Contains/equals

2010-08-19 Thread Karsten Wutzke
Hello, I have an object which has a list of other complex objects. How do I best achieve a complex "contains" comparison based on the object's class? In Java terms, I'm looking for an equivalent to equals(Object) in Python. Does a similar thing exist? Directions appreciated. Karsten -- http://ma