On 17.02.2014 12:47, Serhiy Storchaka wrote:
> 17.02.14 13:14, M.-A. Lemburg написав(ла):
>> Here's a particularly nasty case:
>>
>>>>> l = [(1, None), (2, None)]
>>>>> l.sort()
>>>>> l
>> [(1, None), (2, None)]
>>
>>>>> l = [(1, None), (2, None), (3, 4)]
>>>>> l.sort()
>>>>> l
>> [(1, None), (2, None), (3, 4)]
>>
>>>>> l = [(1, None), (2, None), (3, 4), (2, 3)]
>>>>> l.sort()
>> Traceback (most recent call last):
>>    File "<stdin>", line 1, in <module>
>> TypeError: unorderable types: int() < NoneType()
> 
> If you replace None to another value that cannot be compared with int (e.g. 
> string), you will got
> the same nasty case.

Yes, but that's not the point. Unlike strings or other mixed types that
you cannot compare, None is used as placeholder in data processing as
special value to mean "no value available".

You intentionally use such values in programming. It's not a bug to
have None in a data list or as value of a variable.

-- 
Marc-Andre Lemburg
Director
Python Software Foundation
http://www.python.org/psf/
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to