Unexpected results comparing float to Fraction
steve+comp.lang.python at pearwood.info
Mon Jul 29 19:29:48 CEST 2013
On Mon, 29 Jul 2013 13:08:20 -0400, Terry Reedy wrote:
> In other words, there can be multiple unequal Franctions that have the
> same float value: for instance, Fraction(1,3) and
> Fraction(6004799503160661, 18014398509481984)
> > So from that standpoint it makes sense to me to cast to Fraction when
> > comparing.
> Otherwise, == becomes non-transitive
This is Python, and we can make __eq__ methods that do anything,
including be non-transitive, non-reflexive, and nonsensical if we like :-)
But I take your point, and that makes sense.
More information about the Python-list