test whether 2 objects are equal
- From: Yves Glodt <y.glodt@xxxxxxxxxxxxxxx>
- Date: Tue, 31 Jan 2006 10:45:29 +0100
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 = 'a' test2.var2 = 'b'
if test1 == test2: print "equal" else: print "not equal"
What am I doing wrong...?
best regards, Yves
.
- Follow-Ups:
- Re: test whether 2 objects are equal
- From: bruno at modulix
- Re: test whether 2 objects are equal
- From: Rene Pijlman
- Re: test whether 2 objects are equal
- Prev by Date: Re: Costly object creation (was : Having Trouble with Scoping Rules)
- Next by Date: Request for suggesstions and comments
- Previous by thread: finding the intersection of a list of Sets
- Next by thread: Re: test whether 2 objects are equal
- Index(es):