Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: jmp Newsgroups: comp.lang.python Subject: Re: Pythonic love Date: Tue, 08 Mar 2016 18:00:37 +0100 Lines: 29 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de zEPtjU65uV3E0xS89Lj5TQRfHdP/9VSWiSGYtOEgXJgA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'expressions': 0.07; 'generators': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'wrong,': 0.09; 'python': 0.10; 'def': 0.13; 'iterable)': 0.16; 'iterable:': 0.16; 'justin': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'do.': 0.22; 'function:': 0.22; 'cheers,': 0.22; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'yield': 0.27; 'correct': 0.28; "i'm": 0.30; 'probably': 0.31; 'statement': 0.32; 'usually': 0.33; 'list': 0.34; 'functions.': 0.35; 'but': 0.36; 'cases': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'version': 0.38; 'to:addr:python.org': 0.40; 'hello,': 0.40; 'received:194': 0.61; 'charset:windows-1252': 0.62; 'different': 0.63; 'walters': 0.84 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: paris.sequans.com User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:104347 On 03/08/2016 05:49 PM, justin walters wrote: > Correct me if I'm wrong, but don't python generators usually use the yield > statement so they can be used in list comprehensions? Hello, Please don't top post. Generator expressions are different from generator functions. They are both generators but use a different syntax. generator function: def func(iterable): for i in iterable: yield i the generator expression version would be (i for i in iterable) Both have their use cases but everytime you can actually use an generator expression, it's probably the correct thing to do. Cheers, jm