Possible Duplicate:
How does Python compare string and int?
An intern was just asking me to help debug code that looked something like this:
widths = [image.width for image in images]
widths.append(374)
width = max(widths)
...when the first line should have been:
widths = [int(image.width) for image in images]
Thus, the code was choosing the string '364' rather than the integer 374. How on earth does python compare a string and an integer? I could understand comparing a single character (if python had a char
datatype) to an integer, but I don't see any straightforward way to compare a string of characters to an integer.