> 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.
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 ?
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> > _______________________________________ >
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.