[docs] tutorial example bug: filter function

Schaffer, Steve (317J) steven.r.schaffer at jpl.nasa.gov
Wed Mar 2 22:36:53 CET 2011


There is a bug in the first example (or at least bug in the description of it) at:
http://docs.python.org/tutorial/datastructures.html#functional-programming-tools

The prose introducing the example reads:
 "For example, to compute primes up to 25:"

And then the actual example shows output:
  "[5, 7, 11, 13, 17, 19, 23]"

The actual list of prime numbers less than 25 should include both 2 and 3:
  "[2, 3, 5, 7, 11, 13, 17, 19, 23]"

The filter f(x) in the example actually tests for multiples of 2 or 3, it does not test for compositeness.


I think the example of filter functions would be demonstrated adequately with a simpler filter
  def f(x): return x % 2 == 0
  filter(f, range(1,10))

With the corresponding description
  For example, to find the even number up to 10:


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20110302/a118caa7/attachment-0001.html>


More information about the docs mailing list