Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #85225 > unrolled thread

Re: basic generator question

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2015-02-04 10:15 -0700
Last post2015-02-04 10:15 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: basic generator question Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-04 10:15 -0700

#85225 — Re: basic generator question

FromIan Kelly <ian.g.kelly@gmail.com>
Date2015-02-04 10:15 -0700
SubjectRe: basic generator question
Message-ID<mailman.18471.1423070186.18130.python-list@python.org>
On Wed, Feb 4, 2015 at 6:23 AM, Neal Becker <ndbecker2@gmail.com> wrote:
> class rpt:
>   def __init__ (self, value, rpt):
>     self.value = value; self.rpt = rpt
>   def __call__ (self):
>     for i in range (self.rpt):
>       yield self.value

Note that this class is just reimplementing itertools.repeat.

>>> list(itertools.repeat('hello', 5))
['hello', 'hello', 'hello', 'hello', 'hello']

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web