[docs] [issue32118] Docs: add note about sequence comparisons containing non-orderable elements

Dubslow report at bugs.python.org
Wed Nov 22 23:27:01 EST 2017


New submission from Dubslow <bunslow at gmail.com>:

In sequence comparisons, the enforcement of reflexivity of elements means that only non-identical elements are actually compared. The docs then note, with example, that non-reflexive elements thus always "compare" equal inside the sequence.
    
    This patch adds a second corollary, that non-orderable singletons (e.g. None) will also not break sequence comparison.
    
    Yes, the consequence is logically derivable from the statement "element identity is compared first, and element comparison is performed only for distinct elements", but the first example is given because "For non-reflexive elements, the result is different than for strict element comparison, and may be surprising", which also holds for the example I add here: different from strict element comparison, which may lead to otherwise surprising results (it sure was surprising to me when I expected a list with Nones to fail to compare, hence why I went trawling through the docs). In the manner of the first example, explicit is better than implicit, and (I believe) it will be helpful for readers to have this second consequence demonstrated.

----------
assignee: docs at python
components: Documentation
messages: 306780
nosy: Dubslow, docs at python
priority: normal
severity: normal
status: open
title: Docs: add note about sequence comparisons containing non-orderable elements
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32118>
_______________________________________


More information about the docs mailing list