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


Groups > comp.lang.python > #85225

Re: basic generator question

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'value,': 0.04; '(self,': 0.09; '__init__': 0.09; 'subject:question': 0.10; 'def': 0.12; '(self):': 0.16; 'subject:generator': 0.16; 'value;': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'feb': 0.22; '>>>': 0.22; 'skip:l 30': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'class': 0.32; 'received:google.com': 0.35; 'yield': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'range': 0.61; '2015': 0.84; 'self.value': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=tH+IqQUdPCHQmBXUR1XN5P2dRMhQa6u1p/7L0PhnTf8=; b=HUB5okl21OyTyzbCN/fLurCX1ajn2Ts77Tpf71F3TELmpZN3JrYklhdmnQrwVq7lyw FXpBEXX5/Nj1xD1ic50x1h+Wc1g7qjWp8E/Ylf2d4iZDv56kWLOVtY8m4dP1/BQyqfIP /YrDHQMTpCoffSofJE2lCxy3veZAYXP40WnXJ8f7UNH9jadRbu34GAhyLZxdlzTOBk7i 4Zc7Pcl66DilSPTPOvhLzc867Vn38mIEDs962sPFsLp8wdcYaf/Gw1tsrls7O7mndu99 MoytQ8tzvOS2qi8AlRBvWEOoiKWDg4epVNqO/pw1UanhKHpocQHcDhI3r9pdZZgbPqJ2 4DGQ==
X-Received by 10.68.57.233 with SMTP id l9mr3882443pbq.114.1423070176244; Wed, 04 Feb 2015 09:16:16 -0800 (PST)
MIME-Version 1.0
In-Reply-To <mat6gt$e4j$1@ger.gmane.org>
References <mat6gt$e4j$1@ger.gmane.org>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Wed, 4 Feb 2015 10:15:35 -0700
Subject Re: basic generator question
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.18471.1423070186.18130.python-list@python.org> (permalink)
Lines 12
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1423070186 news.xs4all.nl 2874 [2001:888:2000:d::a6]:59655
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:85225

Show key headers only | View raw


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']

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web