Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'chunk': 0.07; '[0,': 0.09; 'before.': 0.09; 'lst': 0.09; 'consume': 0.16; 'from:addr:pobox.com': 0.16; 'from:addr:skip': 0.16; 'itertools': 0.16; 'subject:doc': 0.16; 'skip': 0.17; 'yield': 0.17; 'thanks,': 0.18; 'examples': 0.18; 'sender:addr:gmail.com': 0.18; 'trying': 0.21; 'example': 0.23; 'this:': 0.23; "i've": 0.23; 'seems': 0.23; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'function': 0.30; 'figure': 0.30; 'url:python': 0.32; 'print': 0.32; 'received:74.125.82': 0.33; 'to:addr:python-list': 0.33; 'equal': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'whatever': 0.35; 'something': 0.35; 'list.': 0.35; 'really': 0.36; 'received:74.125': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'anything': 0.36; 'should': 0.36; 'url:docs': 0.38; 'to:addr:python.org': 0.39; 'here:': 0.62; '26,': 0.65 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:sender:date:x-google-sender-auth:message-id :subject:from:to:content-type; bh=LYzHHKkE6mnZlhxjOzPUcci7ZHgyW7WBlJqGh8FZWVE=; b=htvFz5ZmWaNwtxn2x9eANUKtHyDQOhXu9n1V+cXihqM4RBm7n0AExw7wuWObgj7akf soe6RMFR+mmtBr9lImxtXAmxwFC7soGgDzfJs5dq5Lpve22Bdch0Wj2JutB+/G3DqPk+ s/6TfwMM+vZMsaYdJzCO3/mRst11QhV27P356no1m0k9DaEuOxiJzMVGNdI09VE6Lehv cKXjHliocT2cRmWyCnTlK6AoXDAac2A8hiMrOi6BP0qXbmhhLSSnadOHfDYSuV3hZ0HC YjKvOLfFotgGfS+VPqa7PalQG292SLImTshjNvW7gNq8xWQMAQHKwOXTxrLPQTGl124P uElA== MIME-Version: 1.0 X-Received: by 10.194.63.240 with SMTP id j16mr6542340wjs.45.1362774510450; Fri, 08 Mar 2013 12:28:30 -0800 (PST) Sender: skip.montanaro@gmail.com Date: Fri, 8 Mar 2013 14:28:30 -0600 X-Google-Sender-Auth: qosMyjygdiZg0aFvsd4yUg1MHHA Subject: itertools doc example "consume" From: Skip Montanaro To: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362774511 news.xs4all.nl 6844 [2001:888:2000:d::a6]:58084 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40896 I've never really used itertools before. While trying to figure out how to break a list up into equal pieces, I came across the consume function in the examples here: http://docs.python.org/2/library/itertools.html It seems to me that it should return whatever it consumes from the list. I thought you would call it like this: for chunk in consume(range(30), 5): print chunk and see it print something like [0, 1, 2, 3, 4] [5, 6, 7, 8, 9] ... [25, 26, 27, 28, 29] If I call it like this: lst = range(30) consume(lst, 5) it doesn't actually consume anything from lst. Am I missing something, or is that example missing a return or yield statement? Thanks, Skip