Raymond Hettinger <[EMAIL PROTECTED]> added the comment: Recommend not "doing anything" about decimals and other numbers. What you're seeing is a predictable consequence of NotImplemented being returned by some but not all cross type comparisons. IMO, it is perfectly reasonable that both decimals and floats can be compared to integers but not to each other. Integers are a "universal donor" in this respect but the two float types are not.
It is true that equality should be transitive but the same cannot be said for the *ability of types* to be compared. Unfortunately, the == operator masks what is going on by returning False instead of raising a NotImplementedError. IOW, it the apparant loss of transitivity when "float(2) == Decimal(2)" returns False is an illusion; instead, the False return means that the types cannot be compared at all. If any doc changes are made with respect to this issue, it should be in the docs for the == and != operators and for NotImplemented. ---------- assignee: -> georg.brandl components: +Documentation nosy: +georg.brandl priority: normal -> low title: equality involving Decimals is not transitive; strange set behaviour results -> Document the effects of NotImplemented on == and != _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4087> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com