This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2015年04月17日 07:22 by wim.glenn, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| issue23986.diff | jedwards, 2015年04月17日 17:06 | review | ||
| Messages (5) | |||
|---|---|---|---|
| msg241317 - (view) | Author: wim glenn (wim.glenn) * | Date: 2015年04月17日 07:22 | |
The comparisons section of the python 2 docs says: --- https://docs.python.org/2/reference/expressions.html#comparisons For the list and tuple types, x in y is true if and only if there exists an index i such that x == y[i] is true. --- But it's not strictly speaking correct. Simplest counter-example: x = float('nan') y = [x] The python 3 docs instead mention correct equivalent which is any(x is e or x == e for e in y) |
|||
| msg241344 - (view) | Author: James Edwards (jedwards) * | Date: 2015年04月17日 17:06 | |
What about: For the list and tuple types, ``x in y`` is true if and only if there exists an -index *i* such that ``x == y[i]`` is true. +index *i* such that either ``x == y[i]`` or ``x is y[i]`` is true. Seems to address your issue, and match the semantics of the Python3 any() approach. |
|||
| msg241363 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2015年04月17日 20:25 | |
Those two should be in the reverse order, though. Identity is checked before equality. But why not backport the python3 wording? (Note that there is an open issue for slightly improving that wording). |
|||
| msg241598 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2015年04月20日 04:05 | |
I'll add James' suggested wording, but with the reversed-order suggested by David Murray. |
|||
| msg264230 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2016年04月26日 07:59 | |
New changeset aba647a34ed4 by Raymond Hettinger in branch '2.7': Issue #23986: Note that the in-operator for lists and tuples check identity before equality. https://hg.python.org/cpython/rev/aba647a34ed4 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:15 | admin | set | github: 68174 |
| 2016年04月26日 08:00:31 | rhettinger | set | status: open -> closed resolution: fixed |
| 2016年04月26日 07:59:24 | python-dev | set | nosy:
+ python-dev messages: + msg264230 |
| 2016年01月03日 10:06:50 | ezio.melotti | set | stage: patch review |
| 2015年04月20日 04:05:23 | rhettinger | set | assignee: docs@python -> rhettinger messages: + msg241598 nosy: + rhettinger |
| 2015年04月17日 20:25:51 | r.david.murray | set | nosy:
+ r.david.murray messages: + msg241363 |
| 2015年04月17日 17:06:31 | jedwards | set | files:
+ issue23986.diff nosy: + jedwards messages: + msg241344 keywords: + patch |
| 2015年04月17日 07:22:58 | wim.glenn | create | |