2009/4/3 R. David Murray <rdmur...@bitdance.com>: > a == b > > So, python calls a.__eq__(b) > > Now, that function does: > > a.key == b > > Since b is an object with an __eq__ method, python calls > b.__eq__(a.key).
That's the bit I can't actually find documented anywhere. Ah, looking again I see that I misread the section describing the rich comparison methods: """ There are no swapped-argument versions of these methods (to be used when the left argument does not support the operation but the right argument does); rather, __lt__() and __gt__() are each other’s reflection, __le__() and __ge__() are each other’s reflection, and __eq__() and __ne__() are their own reflection. """ I read that as meaning that no "reversed" version was called, whereas it actually means that __eq__ is its own reversed version - and so gets called both times. Thanks for helping me clear that up! Paul. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com