[issue29756] Improve documentation for list methods that compare items by equality

Steven D'Aprano report at bugs.python.org
Wed Mar 8 10:01:57 EST 2017


Steven D'Aprano added the comment:

Further to Barry's explanation, you see the same result with any values which compare equal:

py> from decimal import Decimal as D
py> [1, 1.0, D(1), True, 1+0j].count(D(1))
5

This is standard behaviour for methods `count`, `remove`, and `index`, but it isn't explained well in the documentation. E.g. `remove` says "Remove the first item from the list whose value is x` which could be read as meaning that the test is done by identity. All three methods need to clarify that ordinary == equality is used.


I'm going to re-open the task as a documentation issue.

----------
assignee:  -> docs at python
components: +Documentation
nosy: +docs at python, steven.daprano
resolution: not a bug -> 
stage: resolved -> 
status: closed -> open
title: List count() counts True as 1 -> Improve documentation for list methods that compare items by equality
type:  -> enhancement
versions:  -Python 2.7, Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29756>
_______________________________________


More information about the Python-bugs-list mailing list