Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.109.133.87.MISMATCH!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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.073 X-Spam-Evidence: '*H*': 0.86; '*S*': 0.00; '"""': 0.05; 'underlying': 0.09; 'stored': 0.10; 'advanced,': 0.16; 'iterable': 0.16; 'iterator': 0.16; 'result:': 0.16; 'wrote:': 0.17; 'feb': 0.19; 'trying': 0.21; 'header:In-Reply-To:1': 0.25; '(which': 0.26; 'am,': 0.27; 'list:': 0.27; 'message-id:@mail.gmail.com': 0.27; 'noticed': 0.28; 'source': 0.29; 'returned': 0.30; 'to:addr :python-list': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'needed': 0.35; 'so,': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'should': 0.36; 'itself': 0.37; 'previous': 0.37; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'to:addr:python.org': 0.39; 'strange': 0.62; '26,': 0.65; 'stated': 0.69; '2013': 0.84; 'andrea': 0.84; 'shared,': 0.84; 'to:name:python': 0.84; 'shares': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=0IojcHRC/iA7sP8gXY7bhoEq5SkLNT0Nzu6Dg3sx2Bg=; b=hoqqAdBIk14G9QrjKm1lcqvQP5uiz4TY21uVqR4ACe9QF9E40spHaDD4pxumf1OdLq 56W+n7/yQYI0MW4AMI6cUhUnuYWo/rFdyFSHzpX+oHzQLf7IgNvMlWKHR717SI64A4Gx 9qfClsHDyt020QLeI+7EuA6ugPdG5/hc5FBZpLDM7CXjcrAOyvgp9DNdmi8dpeydrBvE fcjG6+XG49n65xJWoQdDBJx3TozYHBNM/OUY8lkiiuOLN0nqt+tazn3KOVaQiH7zFxxC M8x7Cok+4ce/XTosw0UR6BsofITmCj2SwVskGdrW0KXi8WQtSIgjBAwxSSo1mELVBaFA 9Opw== X-Received: by 10.59.11.67 with SMTP id eg3mr12329754ved.31.1361897633193; Tue, 26 Feb 2013 08:53:53 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Tue, 26 Feb 2013 09:53:13 -0700 Subject: Re: groupby behaviour To: Python Content-Type: text/plain; charset=ISO-8859-1 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: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1361897635 news.xs4all.nl 6927 [2001:888:2000:d::a6]:49911 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:39970 On Tue, Feb 26, 2013 at 9:27 AM, andrea crotti wrote: > So I was trying to use groupby (which I used in the past), but I > noticed a very strange thing if using list on > the result: As stated in the docs: """ The returned group is itself an iterator that shares the underlying iterable with groupby(). Because the source is shared, when the groupby() object is advanced, the previous group is no longer visible. So, if that data is needed later, it should be stored as a list: """