Yield

Mikael Olofsson mikael at isy.liu.se
Wed Jan 10 16:14:38 CET 2007


Mathias Panzenboeck wrote:
> def primes():
> 	yield 1
> 	yield 2
> 	[snip rest of code]
>   

Hmm... 1 is not a prime. See for instance

    http://en.wikipedia.org/wiki/Prime_number

The definition given there is "In mathematics </wiki/Mathematics>, a 
*prime number* (or a *prime*) is a natural number </wiki/Natural_number> 
that has exactly two (distinct) natural number divisors 
</wiki/Divisor>." The important part of the statement is "exactly 
two...divisors", which rules out the number 1.

/MiO



More information about the Python-list mailing list