Re: test whether 2 objects are equal

2006-01-31 Thread Bruno Desthuilliers
Yves Glodt a écrit : > bruno at modulix wrote: > >> Yves Glodt wrote: >> (snip) >>> #!/usr/bin/python >>> >>> class Test: >>> var1 = '' >>> var2 = '' >> >> >> Take care, this creates two *class* variables var1 and var2. For >> *instance* variables, you want: > > > Thanks for making me a

Re: test whether 2 objects are equal

2006-01-31 Thread Yves Glodt
bruno at modulix wrote: > Yves Glodt wrote: >> Hello, >> >> >> I need to compare 2 instances of objects to see whether they are equal >> or not, but with the code down it does not work (it outputs "not equal") >> >> >> #!/usr/bin/python >> >> class Test: >> var1 = '' >> var2 = '' > > Take

Re: test whether 2 objects are equal

2006-01-31 Thread bruno at modulix
Yves Glodt wrote: > Hello, > > > I need to compare 2 instances of objects to see whether they are equal > or not, but with the code down it does not work (it outputs "not equal") > > > #!/usr/bin/python > > class Test: > var1 = '' > var2 = '' Take care, this creates two *class* variab

Re: test whether 2 objects are equal

2006-01-31 Thread Yves Glodt
Rene Pijlman wrote: > Yves Glodt: >> I need to compare 2 instances of objects to see whether they are equal >> or not, > > This prints "equal": thank you! Have a nice day, Yves > class Test(object): > def __init__(self): > self.var1 = '' > self.var2 = '' > def __eq__(sel

Re: test whether 2 objects are equal

2006-01-31 Thread Rene Pijlman
Yves Glodt: >I need to compare 2 instances of objects to see whether they are equal >or not, This prints "equal": class Test(object): def __init__(self): self.var1 = '' self.var2 = '' def __eq__(self,other): return self.var1 == other.var1 and self.var2 == other.v

Re: test whether 2 objects are equal

2006-01-31 Thread Fredrik Lundh
Yves Glodt wrote > I need to compare 2 instances of objects to see whether they are equal > or not, but with the code down it does not work (it outputs "not equal") > > #!/usr/bin/python > > class Test: > var1 = '' > var2 = '' > > test1 = Test() > test1.var1 = 'a' > test1.var2 = 'b' > > test2 = Te

test whether 2 objects are equal

2006-01-31 Thread Yves Glodt
Hello, I need to compare 2 instances of objects to see whether they are equal or not, but with the code down it does not work (it outputs "not equal") #!/usr/bin/python class Test: var1 = '' var2 = '' test1 = Test() test1.var1 = 'a' test1.var2 = 'b' test2 = Test() test2.var1