[New-bugs-announce] [issue22868] Minor error in the example of filter()

Yi Bai report at bugs.python.org
Fri Nov 14 07:34:23 CET 2014


New submission from Yi Bai:

Hi, I suppose there is a minor error in the example of the filter() function in 5.1.3 part of the document.

------------------------------------------------------------------
filter(function, sequence) returns a sequence consisting of those items from the sequence for which function(item) is true. If sequence is a string or tuple, the result will be of the same type; otherwise, it is always a list. For example, to compute a sequence of numbers not divisible by 2 or 3:

>>>
>>> def f(x): return x % 2 != 0 and x % 3 != 0
...
>>> filter(f, range(2, 25))
[5, 7, 11, 13, 17, 19, 23]
------------------------------------------------------------------

I think what the example does is "to compute a sequence of numbers not divisible by 2 and 3", not "2 or 3".

----------
assignee: docs at python
components: Documentation
messages: 231149
nosy: docs at python, enchyisle
priority: normal
severity: normal
status: open
title: Minor error in the example of filter()
type: resource usage

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


More information about the New-bugs-announce mailing list