[Tutor] class initialization with a lot of parameters
Emile van Sebille
emile at fenx.com
Wed Nov 11 23:30:26 CET 2009
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
More information about the Tutor
mailing list