comparing strings and integers
beliavsky at aol.com
beliavsky at aol.com
Thu May 20 11:25:22 EDT 2004
Thanks to S. Nowaczyk and others for the helpful replies. If one wants
if (a > b)
to raise an exception when the comparison is not "sensible", maybe an
alternative way of writing it is
if ((a - b) > 0)
This should work when 'a' and 'b' are numerical and will fail if one
is numerical and the other is a string. A down side is that it does
not permit string comparisons, but I rarely compare strings except for
equality in my code.
More information about the Python-list
mailing list