Re: Problem comparing object graphs and trees

2006-12-15 Thread Duncan Booth
[EMAIL PROTECTED] wrote: > I swear I am not drunk, but why isn't a1 == a2 and worse why isn't a1 >== a1? Does someone have a clue and can explain to me this suprising > behavior? (python 2.4.3 on Ubuntu 6.06). Because the __cmp__ method doesn't return a boolean. It returns a value <0, 0 or >0 ac

Re: Problem comparing object graphs and trees

2006-12-15 Thread raphael . marvie
I am not drunk but should have rtfm. Sorry and Thanks. r. On Dec 15, 3:04 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > > > $ cat cmp.py > > > class A: > > def __init__(self, b): > > self.b = b > > def __cmp__(self, other): > > return self.b

Re: Problem comparing object graphs and trees

2006-12-15 Thread Peter Otten
[EMAIL PROTECTED] wrote: > > $ cat cmp.py > > class A: > def __init__(self, b): > self.b = b > def __cmp__(self, other): > return self.b == other.b > > class B: > pass > > if __name__ == '__main__': > b = B() > a1 = A(b) > a2 = A(b) > print a1 == a2

Problem comparing object graphs and trees

2006-12-15 Thread raphael . marvie
Dear all, I am trying to compare graphes of object through the use of the __cmp__ operator. Before managing the problem of recursive comparison, I have tried a simple test which result surprises me. Here is the simplest code I can write that presents my problem: $ cat cmp.py class A: def _