On Tue, 27 Jan 2009 00:05:53 +0530 Anjanesh Lekshminarayanan
<m...@anjanesh.net> wrote:

> > You can also replace the whole class with a function thusly:
> >
> >    def two_times(n):
> >        for k in itertools.count(1):
> >            yield n * (2**k)
> >
> > This function is then called a generator (because it generates an
> > iterator). You can now say
> >
> >    infinitely_doubling_numbers = two_times(2)
> >    for number in in infinitely_doubling_numbers:
> >        print number
> 
> Oh..this is new. Will checkup itertools. Thanks.
> 
OK, happy I could help. But my point was the yield statement (in case
you didn't know about yield).

regards
/W

-- 
My real email address is constructed by swapping the domain with the
recipient (local part).
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to