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


Groups > comp.lang.python > #99468

Re: list slice and generators

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Ian Kelly <ian.g.kelly@gmail.com>
Newsgroups comp.lang.python
Subject Re: list slice and generators
Date Wed, 25 Nov 2015 10:45:54 -0700
Lines 11
Message-ID <mailman.81.1448473602.20593.python-list@python.org> (permalink)
References <5654D8CE.2020105@gmail.com> <n3418c$k41$1@ger.gmane.org> <CALwzidmnKPAY+X7tGxPreBXk2JiFnzVAJQ0q-erkcaR7MRtnvw@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de 36DV+cwScoEKb/3+RtSOYgn8kcVtn2ctUFKbzt+l4KKQ==
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.024
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'exercise': 0.03; 'elif': 0.04; 'metrics': 0.09; 'wed,': 0.15; 'calculates': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; '>>>': 0.20; '2015': 0.20; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'subject:list': 0.26; 'message-id:@mail.gmail.com': 0.27; 'function': 0.28; 'that.': 0.30; 'list': 0.34; 'received:google.com': 0.35; 'nov': 0.35; 'list,': 0.36; 'skip:i 20': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'list.': 0.37; 'received:209': 0.38; 'does': 0.39; 'to:addr:python.org': 0.40; 'actually,': 0.84; 'otten': 0.84; 'to:name:python': 0.84; 'average': 0.93
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=AJOjA7wlha2oM1QZ4i/290c/438onvc1w9wk15QXRe8=; b=T1t2FlCW5yl5LD+jNcchAqY4N1efMHlEWSVd3RzW5+I094ru4zm/Ars4SJcU8H109K sGaObtmXfm7JmpLFzsaei+6I7yv76z1szAMx0fjMbH+eCbyoaBNHiwCNImczBy4NSrXt 5Jbs7c+sVYN8VmMqL2wLiGtEF2LlidDzUdNipSwfPpuneHmzv7nZRXp37WHM6YsMAZcl j5hcSyxt/wNw2uNPe9Fbc7B8FOW8TA3ZAQaTKr2I8e+n0ZxseGVZdoMqkGvcX9HJKttc ggxUbZLreO4JfKbulMmfIxfrxRQ7lEvVg+w6JG1A7vZEg9xp3WqhuSxK/SaIP0mYjoFF aXpQ==
X-Received by 10.50.147.36 with SMTP id th4mr5127383igb.68.1448473594149; Wed, 25 Nov 2015 09:46:34 -0800 (PST)
In-Reply-To <CALwzidmnKPAY+X7tGxPreBXk2JiFnzVAJQ0q-erkcaR7MRtnvw@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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>
Xref csiph.com comp.lang.python:99468

Show key headers only | View raw


On Wed, Nov 25, 2015 at 10:44 AM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> On Wed, Nov 25, 2015 at 3:07 AM, Peter Otten <__peter__@web.de> wrote:
>>>     elif name in METRICS_AVG:
>>           # writing a function that calculates the average without
>>           # materialising the list left as an exercise ;)
>
>         metrics = itertools.tee(metrics)
>         return int(sum(metrics[0]) / len(metrics[1]))

Actually, don't do that. It does effectively materialize the list,
just not as a list.

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


Thread

Re: list slice and generators Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-25 10:45 -0700

csiph-web