comparing strings and integers

Roy Smith roy at panix.com
Thu May 20 11:55:44 EDT 2004


In article <3064b51d.0405200725.c19102d at posting.google.com>,
 beliavsky at aol.com wrote:

> 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.

How do you define "sensible"?



More information about the Python-list mailing list