B
beliavsky
By mistake I coded something like
print ("1" > 1)
and got the result "True". Comparing an integer and a string seems
meaningless to me, and I would prefer to have an exception thrown. Can
someone explain why Python allows comparisons between integers and
strings, and how it handles those cases? Why is "1" > 1?
Pychecker does not warn about the line of code above -- I wish it did.
In my code what I really intended was to convert the "1" to an int and
THEN do a comparison.
print ("1" > 1)
and got the result "True". Comparing an integer and a string seems
meaningless to me, and I would prefer to have an exception thrown. Can
someone explain why Python allows comparisons between integers and
strings, and how it handles those cases? Why is "1" > 1?
Pychecker does not warn about the line of code above -- I wish it did.
In my code what I really intended was to convert the "1" to an int and
THEN do a comparison.