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@python
components: Documentation
messages: 231149
nosy: docs@python, enchyisle
priority: normal
severity: normal
status: open
title: Minor error in the example of filter()
type: resource usage
___
Python tracker
<http://bugs.python.org/issue22868>
___
___
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com