Re: A dumb question about a class

2007-08-14 Thread Steven Bethard
[EMAIL PROTECTED] wrote: > Also, does anyone know if there is some magic that makes > i in some_set > loads faster than > i in some_list It's not magic, per se. It's really part of the definition of the data type. Lists are ordered, and are slow when checking containment. Sets are unordered and

Re: A dumb question about a class

2007-08-14 Thread [EMAIL PROTECTED]
On Aug 13, 3:30 am, Steven Bethard <[EMAIL PROTECTED]> wrote: > Dick Moores wrote: > > At 03:35 PM 8/12/2007, Steven Bethard wrote: > >> Note that if you just want to iterate over all the primes, there's no > >> need for the class at all. Simply write:: > > >> forprimein iter_primes(): > > >

Re: A dumb question about a class

2007-08-12 Thread Steven Bethard
Steven Bethard wrote: > Dustan wrote: >> On Aug 12, 7:35 pm, Dustan <[EMAIL PROTECTED]> wrote: >>> On Aug 12, 5:09 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: >>> def iter_primes(): # an iterator of all numbers between 2 and +infinity numbers = itertools.coun

Re: A dumb question about a class

2007-08-12 Thread Steven Bethard
Dick Moores wrote: > At 03:35 PM 8/12/2007, Steven Bethard wrote: >> Note that if you just want to iterate over all the primes, there's no >> need for the class at all. Simply write:: >> >> for prime in iter_primes(): > > Even if I want to test only 1 integer, or want the list of primes in a

Re: A dumb question about a class

2007-08-12 Thread Steven Bethard
Dustan wrote: > On Aug 12, 7:35 pm, Dustan <[EMAIL PROTECTED]> wrote: >> On Aug 12, 5:09 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: >> >>> def iter_primes(): >>> # an iterator of all numbers between 2 and +infinity >>> numbers = itertools.count(2) >>> # generate p

Re: A dumb question about a class

2007-08-12 Thread Dustan
On Aug 12, 7:35 pm, Dustan <[EMAIL PROTECTED]> wrote: > On Aug 12, 5:09 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: > > > def iter_primes(): > > # an iterator of all numbers between 2 and +infinity > > numbers = itertools.count(2) > > > # generate primes forever >

Re: A dumb question about a class

2007-08-12 Thread Dustan
On Aug 12, 5:09 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: > def iter_primes(): > # an iterator of all numbers between 2 and +infinity > numbers = itertools.count(2) > > # generate primes forever > while True: > > # get the first number from

Re: A dumb question about a class

2007-08-12 Thread Dick Moores
At 03:35 PM 8/12/2007, Steven Bethard wrote: >Note that if you just want to iterate over all the primes, there's no >need for the class at all. Simply write:: > > for prime in iter_primes(): Even if I want to test only 1 integer, or want the list of primes in a certain interval, I don't nee

Re: A dumb question about a class

2007-08-12 Thread Steven Bethard
Dick Moores wrote: > At 03:09 PM 8/12/2007, Steven Bethard wrote: > >> Here's how I'd write the recipe:: >> >> import itertools >> >> def iter_primes(): >> # an iterator of all numbers between 2 and +infinity >> numbers = itertools.count(2) >> >> # generate pri

Re: A dumb question about a class

2007-08-12 Thread Dick Moores
At 03:09 PM 8/12/2007, Steven Bethard wrote: >Here's how I'd write the recipe:: > > import itertools > > def iter_primes(): > # an iterator of all numbers between 2 and +infinity > numbers = itertools.count(2) > > # generate primes forever > while True

Re: A dumb question about a class

2007-08-12 Thread Steven Bethard
Dick Moores wrote: > I'm still trying to understand classes. I've made some progress, I > think, but I don't understand how to use this one. How do I call it, or > any of its functions? It's from the Cookbook, at > . The short answ

A dumb question about a class

2007-08-12 Thread Dick Moores
I'm still trying to understand classes. I've made some progress, I think, but I don't understand how to use this one. How do I call it, or any of its functions? It's from the Cookbook, at . Thanks, Dick Moores ===