Comparing floats to Fractions gives unexpected results:
# Python 3.3
py> from fractions import Fraction
py> 1/3 == Fraction(1, 3)
py> 1/3 == float(Fraction(1, 3))
I expected that float-to-Fraction comparisons would convert the Fraction to a float, but apparently they do the opposite: they convert the float to a Fraction:
Am I the only one who is surprised by this? Is there a general rule for which way numeric coercions should go when doing such comparisons?