Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.032 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'subsequent': 0.05; '22,': 0.09; 'inserts': 0.09; 'cc:addr:python-list': 0.11; 'comp': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hmm.': 0.16; 'reasonably': 0.16; 'wrote:': 0.18; 'solution.': 0.20; 'cc:addr:python.org': 0.22; 'instance,': 0.24; 'fine': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'record': 0.27; 'function': 0.29; 'dec': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'that.': 0.31; 'bunch': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'values.': 0.31; 'could': 0.34; 'received:google.com': 0.35; 'subject:List': 0.36; 'list': 0.37; 'pm,': 0.38; 'use.': 0.39; 'sure': 0.39; 'called': 0.40; 'subject:skip:C 10': 0.61; 'new': 0.61; "you're": 0.61; 'save': 0.62; 'making': 0.63; 'side': 0.67; 'records': 0.73; 'id,': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=i9Q3aVxM8wKj6xPt9YL+55eto0IwqDPaqrFS9W+rECg=; b=t9Pvi+PrH6jDlBsnUCY/VMH1dc/IQOjsfLYUnZ1oYc13OIMMuZPPUVLG0VbVPaKdyX vxTsTTKcxF7flGfcA7JqWlVwE+dMvxFbq10s1Rek/MQBK0mZxfq4gDv9cccuYN1R3buY 5YeuzFIftxmrk2YSL0PDzcc0+kgAVQ08yDkV0mFjh1iO/+UnJmNPAQhE7Du3MqOGI/GS vesr0XTVobJW2EDW5oiE63PrxBL634FlZygatRXrHAeYhegJQiGTL3lBqHgwEGBSPPCs fiQRAAN3H9TM4VN/DB7O1CfsbSM13I5aMaTHc4BwKx5hJT1gMQ80M5J24rtOq+Y6nAF2 2OMA== MIME-Version: 1.0 X-Received: by 10.50.79.135 with SMTP id j7mr15033475igx.14.1419241529708; Mon, 22 Dec 2014 01:45:29 -0800 (PST) In-Reply-To: <5497e2a2$0$12978$c3e8da3$5496439d@news.astraweb.com> References: <5497e2a2$0$12978$c3e8da3$5496439d@news.astraweb.com> Date: Mon, 22 Dec 2014 20:45:29 +1100 Subject: Re: List Comprehensions From: Chris Angelico Cc: "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: 11 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1419241532 news.xs4all.nl 2977 [2001:888:2000:d::a6]:35679 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82766 On Mon, Dec 22, 2014 at 8:21 PM, Steven D'Aprano wrote: > If the called function has side-effects, a list comp is not a good solution. Hmm. I'm not so sure about that. Side effects are fine in a list comp, as long as you're making use of the return values. For instance, if you have a function that inserts a record to a database and returns the new ID, you could reasonably use a list comp to save a bunch of records and get a list of IDs for subsequent use. ChrisA