On Jan 10, 1:26 pm, Hellmut Weber <m...@hellmutweber.de> wrote: > Hi, > being a causal python user (who likes the language quite a lot) > it took me a while to realize the following: > > l...@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 m...@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
I would say you want to compare semantically an integer value with an integer value so why not: IDLE 1.1.3 >>> max = '5' >>> n = 5 >>> n==(int(max)) True >>> ? (in Python 2.4...) Regards, Marco -- http://mail.python.org/mailman/listinfo/python-list