Hi,
thanks to all who answered.
I'm using Python 2.6.5 on my machine and consulted the corresponding
documentation.
I do appreciate the modified definition of python 3, that seems much
more reasonable.
Thanks for indicating.
Greetings from Munich in Winter
Hellmut
Am 10.01.2010 17:34, schrieb Nobody:
Hellmut Weber wrote:
being a causal python user (who likes the language quite a lot)
it took me a while to realize the following:
>>> max = '5'
>>> n = 5
>>> n>= max
False
Section 5.9 Comparison describes this.
Can someone give me examples of use cases
Peter Otten wrote:
The use cases for an order that works across types like int and str are weak
to non-existent. Implementing it was considered a mistake and has been fixed
in Python 3:
5> "5"
Traceback (most recent call last):
File "<stdin>", line 1, in<module>
TypeError: unorderable types: int()> str()
If you actually need to perform comparisons across types, you can rely
upon the fact that tuple comparisons are non-strict and use e.g.:
> a = 5
> b = '5'
> (type(a).__name__, a)< (type(b).__name__, b)
True
> (type(a).__name__, a)> (type(b).__name__, b)
False
The second elements will only be compared if the first elements are equal
(i.e. the values have the same type).
--
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
--
http://mail.python.org/mailman/listinfo/python-list