Plea for __eql__

Michael Ackerman ack at simplyweb.net
Sun May 21 16:54:42 EDT 2000


Hi. 
Often there is only a partial order, or no natural order at all, on the
instances of a class (eg sets, finite fields), but one still wants to
ask whether two instances are equal (in a way appropriate for that
type). To overload '==' for this purpose one now has to go through
__cmp__, it seems to me, and so impose a sometimes artificial linear
order. Wouldn't it be handy to have an __eql__ ? As things are now, it
seems that there is no way to have '<' raise an exception without also
having '!=' raise an exception in unwanted cases. Am I wrong?
	More generally, would it be difficult to change Python so that
programmers could define their own infix methods? Would it be desirable?
(The modern functional languages allow this, without anarchy.)

						-- Michael





More information about the Python-list mailing list