--- Steven Bethard <[EMAIL PROTECTED]> wrote: > On 6/12/07, Steve Howell <[EMAIL PROTECTED]> > wrote: > > --- Steven Bethard <[EMAIL PROTECTED]> > wrote: > > > import itertools > > > > > > def iter_primes(): > > > # an iterator of all numbers between 2 and > > > +infinity > > > numbers = itertools.count(2) > > > > > > # generate primes forever > > > while True > > > > > > # generate the first number from the > > > iterator, > > > # which should always be a prime > > > prime = numbers.next() > > > yield prime > > > > > > # lazily remove all numbers from the > > > iterator that > > > # are divisible by prime we just > selected > > > numbers = > itertools.ifilter(prime.__rmod__, > > > numbers) > > > > > > I think that's 17-ish, though you could shrink > it > > > down by removing some > > > of the spaces. > > > > No, that's perfect. Do you want me to post it, or > do > > you want the honors? > > Go for it. >
Done: http://wiki.python.org/moin/SimplePrograms (example 20) Thanks, George and Steve! ____________________________________________________________________________________ Need Mail bonding? Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users. http://answers.yahoo.com/dir/?link=list&sid=396546091 -- http://mail.python.org/mailman/listinfo/python-list