Message231149
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". |
|
Date |
User |
Action |
Args |
2014-11-14 06:34:23 | enchyisle | set | recipients:
+ enchyisle, docs@python |
2014-11-14 06:34:23 | enchyisle | set | messageid: <1415946863.39.0.61005418871.issue22868@psf.upfronthosting.co.za> |
2014-11-14 06:34:23 | enchyisle | link | issue22868 messages |
2014-11-14 06:34:22 | enchyisle | create | |
|