integer and string compare, is that correct?

Hellmut Weber mail at hellmutweber.de
Sun Jan 10 07:26:00 EST 2010


Hi,
being a causal python user (who likes the language quite a lot)
it took me a while to realize the following:


leo at sylvester py_count $ python
Python 2.6.3 (r263:75183, Oct 26 2009, 12:34:23)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> max = '5'
 >>> n = 5
 >>> n >= max
False
 >>> n + max
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'str'
 >>>


Section 5.9 Comparison describes this.

Can someone give me examples of use cases

TIA

Hellmut

-- 
Dr. Hellmut Weber         mail at hellmutweber.de
Degenfeldstraße 2         tel   +49-89-3081172
D-80803 München-Schwabing mobil +49-172-8450321
please: No DOCs, no PPTs. why: tinyurl.com/cbgq




More information about the Python-list mailing list