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


Groups > comp.lang.python > #40905

Re: itertools doc example "consume"

Path csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'discard': 0.05; 'python': 0.09; 'bit...': 0.09; 'lst': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'consume': 0.16; 'from:addr:pobox.com': 0.16; 'from:addr:skip': 0.16; 'iterable': 0.16; 'iterator': 0.16; 'iterator,': 0.16; 'iterator.': 0.16; 'iterators': 0.16; 'itertools': 0.16; 'message-id:@post.gmane.org': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:doc': 0.16; 'skip': 0.17; 'object.': 0.22; 'pass': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.28; 'implicitly': 0.29; 'writes:': 0.29; 'stuff': 0.30; 'to:addr :python-list': 0.33; 'version': 0.34; 'thanks': 0.34; 'received:org': 0.36; 'but': 0.36; 'charset:us-ascii': 0.36; 'does': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'list,': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'range': 0.60; 'special': 0.73
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Skip Montanaro <skip@pobox.com>
Subject Re: itertools doc example "consume"
Date Fri, 8 Mar 2013 21:43:21 +0000 (UTC)
References <CANc-5UxWmbhgwNpx195KO8j3HvDEPa8shdzF1fxOhWB2mxYT-Q@mail.gmail.com> <CALwzidmp=PZAuTJTq5uAsLeMdiQhFonZ3zYY4DH3UmOLedpvOQ@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host sea.gmane.org
User-Agent Loom/3.14 (http://gmane.org/)
X-Loom-IP 192.160.124.65 (Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11)
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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3102.1362779016.2939.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1362779016 news.xs4all.nl 6931 [2001:888:2000:d::a6]:59462
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:40905

Show key headers only | View raw


Ian Kelly <ian.g.kelly <at> gmail.com> writes:

> Depending on your Python version lst is either a range object or a
> list, neither of which is an iterator.  If you pass to consume an
> iterable object that is not an iterator, it will implicitly obtain an
> iterator for it, consume from the iterator, and then discard the
> iterator, with no effect on the original object.
> 
> In general the itertools functions will work equally well on iterators
> and other iterables, but consume is special in that what it does is
> only relevant to iterators.

Thanks for the explanation.  I clearly still need to grapple with this
stuff a bit...

Skip

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


Thread

Re: itertools doc example "consume" Skip Montanaro <skip@pobox.com> - 2013-03-08 21:43 +0000

csiph-web