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


Groups > comp.lang.python > #104347

Re: Pythonic love

Path csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From jmp <jeanmichel@sequans.com>
Newsgroups comp.lang.python
Subject Re: Pythonic love
Date Tue, 08 Mar 2016 18:00:37 +0100
Lines 29
Message-ID <mailman.50.1457456451.15725.python-list@python.org> (permalink)
References <nbl0lo$5o5$1@gioia.aioe.org> <nbmjrf$jrd$1@ger.gmane.org> <CAO1D73GO5ey3_Fskao9Ch3+3FC7HVEGWWZ2T1zjoV1aT2MsS0g@mail.gmail.com>
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 <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.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 <CAO1D73GO5ey3_Fskao9Ch3+3FC7HVEGWWZ2T1zjoV1aT2MsS0g@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:104347

Show key headers only | View raw


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

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


Thread

Pythonic love Fillmore <fillmore_remove@hotmail.com> - 2016-03-07 17:51 -0500
  Re: Pythonic love Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-03-07 22:52 +0000
  Re: Pythonic love sohcahtoa82@gmail.com - 2016-03-07 15:03 -0800
    Re: Pythonic love Fillmore <fillmore_remove@hotmail.com> - 2016-03-07 18:12 -0500
  Re: Pythonic love Ian Kelly <ian.g.kelly@gmail.com> - 2016-03-07 16:13 -0700
  Re: Pythonic love Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-07 23:19 +0000
  Re: Pythonic love jmp <jeanmichel@sequans.com> - 2016-03-08 14:25 +0100
  Re: Pythonic love justin walters <walters.justin01@gmail.com> - 2016-03-08 08:49 -0800
  Re: Pythonic love Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-08 16:55 +0000
  Re: Pythonic love jmp <jeanmichel@sequans.com> - 2016-03-08 18:00 +0100
  Re: Pythonic love justin walters <walters.justin01@gmail.com> - 2016-03-08 09:17 -0800
    Re: Pythonic love jstitch@invernalia.homelinux.net (Javier Novoa C.) - 2016-03-08 11:27 -0600
      Re: Pythonic love Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-03-08 21:10 -0500

csiph-web