SimplePrograms challenge

Steven Bethard steven.bethard at gmail.com
Tue Jun 12 19:20:36 EDT 2007


Steve Howell wrote:
> --- Steven Bethard <steven.bethard at gmail.com> wrote:
>> How about we just comment it better?
>>
>> import itertools
>>
>> def iter_primes():
>>      # an iterator of all numbers between 2 and +infinity
>>      numbers = itertools.count(2)
[snip]
> 
> Actually, just one small caveat--I'd still want the
> program to print out the results.  I think I've
> followed that convention for all the other programs.  

Good point. Adding something as simple as::

     # print the first 100 primes
     for prime in itertools.islice(iter_primes(), 100):
         print prime

to the end should make it a full-fledged program.

STeVe



More information about the Python-list mailing list