On 11/11/2009 10:19 AM Alan Gauld said...
what we actually do in Python is
if number1.__eq__(number2):
In other words we call the special method __eq__() of number1 passing
in number2.
So == is actually a method of the object on the left hand side.
... and sometimes the right hand side. Consider:
>>> class A:
... def __eq__(self,other):
... print 'in A.__eq__'
... return True
...
>>> class C:
... pass
...
>>> c = C()
>>> a == c
in A.__eq__
True
>>> c == a
in A.__eq__
True
>>>
Emile
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor