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
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
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
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
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
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
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