comparing strings and ints
Mark H.H. Montague
montague at maravu.cs.dartmouth.edu
Mon Apr 10 11:32:13 EDT 2000
Does anyone know why it is not a type error to compare a string and an
int with '>' ? For example, I just spent over an hour debugging code
that essentially did this:
>>> 45 > '0'
0
Of course, the '0' was a variable read in from a file, which I forgot
to convert to a string. Bad old perl habits. But I'm having a hard
time imagining a situation where someone would be intentionally and
meaningfully comparing a string and an int.
Any ideas?
-mm
More information about the Python-list
mailing list