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

2017-11-24 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

This whole section has become a mess an is now more complex that the underlying 
code.   Adding more caveats, special cases, and atypical examples will make it 
worse (rather like the U.S. tax code, another example of bad technical writing).

I recommend the whole section be rewritten, extracting the most general rules 
and with examples that cover the general rules.

There can then be brief separate paragraphs for language lawyers that cover 
what makes NaNs and None unusual (none of the comparison logic special cases 
these value -- their interesting behaviors are intrinsic to the object itself).

--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2017-11-23 Thread R. David Murray

R. David Murray  added the comment:

The surprising thing is the behavior of NaN, which is *not equal* to itself.

The statement about orderability says "...are ordered the same as their first 
unequal elements".  This is explicit and unambiguous, there is no difference in 
this context between the number 1 and the singleton None, or the reflexivity 
enforced on NaN: all are equal to the corresponding element from the other 
sequence.  The whole point of the paragraph is that *no order test is done 
until the first unequal element is encountered*.

If we want to make this *more* explicit, I would suggest simply adding the 
following sentence after the first example in the original paragraph: "This 
means that reflexive elements that are otherwise unorderable (such as None and 
NaN) do not trigger a TypeError during a comparison."

--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2017-11-22 Thread Dubslow

Dubslow  added the comment:

The PR includes an unrelated one word grammar fix in the same file, that can be 
removed (by me or by someone else, IDC).

This is possibly backportable but I wouldn't know, and leave such decisions for 
someone who do.

--
type:  -> enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2017-11-22 Thread Roundup Robot

Change by Roundup Robot :


--
keywords: +patch
pull_requests: +4451
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2017-11-22 Thread Dubslow

New submission from Dubslow :

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@python
components: Documentation
messages: 306780
nosy: Dubslow, docs@python
priority: normal
severity: normal
status: open
title: Docs: add note about sequence comparisons containing non-orderable 
elements
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com