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.

classification
Title: docstring of filter function is incorrect
Type: Stage: resolved
Components: Documentation Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Pierre Thibault, anthony-flury, docs@python, miss-islington, ncoghlan, ned.deily, rhettinger
Priority: normal Keywords: patch

Created on 2018-03-06 01:36 by Pierre Thibault, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 6015 merged anthony-flury, 2018-03-07 09:27
Messages (5)
msg313302 - (view) Author: Pierre Thibault (Pierre Thibault) Date: 2018-03-06 01:36
> help(filter)

Help on built-in function filter in module __builtin__:

filter(...)
    filter(function or None, sequence) -> list, tuple, or string

    Return those items of sequence for which function(item) is true.  If
    function is None, return the items that are true.  If sequence is a tuple
    or string, return the same type, else return a list.
(END)

The second argument can be an iterable. Suggestion: Replace the docstring with the definition found at https://docs.python.org/2/library/functions.html#filter.
msg315972 - (view) Author: Anthony Flury (anthony-flury) * Date: 2018-04-30 22:05
Strictly speaking the official Python2 reference document isn't a great example - for instance:

' If function is None, the identity function is assumed, that is, all elements of iterable that are false are removed.' 

Implies that items are removed from the iterable are removed, but they aren't; they are simply not included in the sequence that is returned.

Does the documentation need to be fixed too ?
msg315974 - (view) Author: Pierre Thibault (Pierre Thibault) Date: 2018-04-30 23:03
I guess it does since it gives false information.

2018-04-30 18:05 GMT-04:00 Anthony Flury <report@bugs.python.org>:

>
> Anthony Flury <anthony.flury@btinternet.com> added the comment:
>
> Strictly speaking the official Python2 reference document isn't a great
> example - for instance:
>
> ' If function is None, the identity function is assumed, that is, all
> elements of iterable that are false are removed.'
>
> Implies that items are removed from the iterable are removed, but they
> aren't; they are simply not included in the sequence that is returned.
>
> Does the documentation need to be fixed too ?
>
> ----------
> nosy: +anthony-flury
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue33006>
> _______________________________________
>
msg343849 - (view) Author: miss-islington (miss-islington) Date: 2019-05-29 01:36
New changeset 09ba83330b495afedbb6b27853506fe15a85b461 by Miss Islington (bot) (Tony Flury) in branch '2.7':
[2.7] bpo-33006 - Correct filter doc string to clarify 2nd argument can be iterable (GH-6015)
https://github.com/python/cpython/commit/09ba83330b495afedbb6b27853506fe15a85b461
msg343852 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2019-05-29 02:04
Thanks for the docstring improvement!  It looks like the Library Reference entry for filter has similar wording in 3.x and 2.7 with regard to "items are removed".  If soneone feels strongly that that is not precise enough, suggest supplying a separate doc PR.
History
Date User Action Args
2022-04-11 14:58:58adminsetgithub: 77187
2019-05-29 02:04:01ned.deilysetstatus: open -> closed

nosy: + ned.deily
messages: + msg343852

resolution: fixed
stage: patch review -> resolved
2019-05-29 01:36:18miss-islingtonsetnosy: + miss-islington
messages: + msg343849
2018-04-30 23:03:51Pierre Thibaultsetmessages: + msg315974
2018-04-30 22:05:57anthony-flurysetnosy: + anthony-flury
messages: + msg315972
2018-03-24 05:42:45serhiy.storchakasetnosy: + rhettinger, ncoghlan
2018-03-07 09:27:41anthony-flurysetkeywords: + patch
stage: patch review
pull_requests: + pull_request5782
2018-03-06 01:36:31Pierre Thibaultcreate