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


Groups > comp.lang.python > #81378

RE: Comprehension with two variables - explanation needed

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <skip.montanaro@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.112
X-Spam-Level *
X-Spam-Evidence '*H*': 0.78; '*S*': 0.00; 'subject:two': 0.07; 'cc:addr:python-list': 0.11; 'comp': 0.16; 'covert': 0.16; 'sugar': 0.16; 'syntactic': 0.16; 'cc:addr:gmail.com': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**1': 0.23; 'skip': 0.24; "i've": 0.25; '&gt;': 0.26; 'header:In-Reply-To:1': 0.27; 'especially': 0.30; 'message-id:@mail.gmail.com': 0.30; '(perhaps': 0.31; 'subject:with': 0.35; 'form.': 0.35; 'one,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'example,': 0.37; 'list': 0.37; 'subject:needed': 0.38; 'little': 0.38; 'skip:u 10': 0.60; 'till': 0.61; 'subject:skip:C 10': 0.61; "you're": 0.61; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'now...': 0.84; 'terrible': 0.84; 'picture': 0.97
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:to :cc:content-type; bh=i9whwdtqRuslIekMdIZbz45CCMo4/hHB1xqagnVrISA=; b=NDvxsdTF8ngOcxjoyMkn0Vf/62OgkfuU6YbyzprAE5+h/6ybYaR4DfGXXt+jMCQehA Hy7Z8Xmu7XlsK8FBseLI1j3erMGqqzdaXVRqcBIBgIuOj1+na0udhtVALCcxWBrHkhcm Gaa5+2wYwMC3Vj4roKTmi3L2NyyOr+1cYY2YAW2casyXAegGuT8C4RnFGadaxmgVEFbG 9psw1ZoGULTkC6cGesWhzMHl8nhGlRTd5AHNuYxpLz8x4r3XrCe98/OP717hW55W2Tcy ff0NTy/mlrAzkO2NqjQATo4bDJKoFm6sxZBZ/oNyefrgqRm8rVkauN1jp3eyLHnKzgJd 2E6Q==
MIME-Version 1.0
X-Received by 10.52.9.37 with SMTP id w5mr8543628vda.38.1416757547145; Sun, 23 Nov 2014 07:45:47 -0800 (PST)
In-Reply-To <002501d00733$6995dce0$3cc196a0$@gmail.com>
References <mailman.16184.1416754678.18130.python-list@python.org> <d1194d28-e9ed-4bd3-86e9-899e13a17097@googlegroups.com> <002501d00733$6995dce0$3cc196a0$@gmail.com>
Date Sun, 23 Nov 2014 09:45:47 -0600
Subject RE: Comprehension with two variables - explanation needed
From Skip Montanaro <skip.montanaro@gmail.com>
To Ivan Evstegneev <webmailgroups@gmail.com>
Content-Type multipart/alternative; boundary=20cf302efa2854a3a10508889209
Cc Python <python-list@python.org>, Rustom Mody <rustompmody@gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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>
Newsgroups comp.lang.python
Message-ID <mailman.16191.1416757555.18130.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1416757555 news.xs4all.nl 2973 [2001:888:2000:d::a6]:57731
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:81378

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

> But it breaks all the picture that I've built in my head about comps till
> now...

Note that list comprehensions are little more than syntactic sugar for for
loops. If you're having terrible writing or understanding one, especially a
compound one like your example, it can help to write it as a (nested) for
loop, then covert it (perhaps incrementally) to the list comp form.

Skip

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


Thread

Comprehension with two variables - explanation needed "Ivan Evstegneev" <webmailgroups@gmail.com> - 2014-11-23 16:56 +0200
  Re: Comprehension with two variables - explanation needed Rustom Mody <rustompmody@gmail.com> - 2014-11-23 07:09 -0800
    RE: Comprehension with two variables - explanation needed "Ivan Evstegneev" <webmailgroups@gmail.com> - 2014-11-23 17:37 +0200
    Re: Comprehension with two variables - explanation needed Chris Angelico <rosuav@gmail.com> - 2014-11-24 02:42 +1100
    RE: Comprehension with two variables - explanation needed Skip Montanaro <skip.montanaro@gmail.com> - 2014-11-23 09:45 -0600
      Re: Comprehension with two variables - explanation needed Roy Smith <roy@panix.com> - 2014-11-23 10:57 -0500
        Re: Comprehension with two variables - explanation needed Rustom Mody <rustompmody@gmail.com> - 2014-11-23 08:45 -0800
          Re: Comprehension with two variables - explanation needed Rustom Mody <rustompmody@gmail.com> - 2014-11-23 09:17 -0800
          RE: Comprehension with two variables - explanation needed "Ivan Evstegneev" <webmailgroups@gmail.com> - 2014-11-23 19:27 +0200
          Re: Comprehension with two variables - explanation needed Steven D'Aprano <steve@pearwood.info> - 2014-11-24 04:42 +0000
            Re: Comprehension with two variables - explanation needed Chris Angelico <rosuav@gmail.com> - 2014-11-24 15:51 +1100
              Re: Comprehension with two variables - explanation needed Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-25 09:20 +1100
            Re: Comprehension with two variables - explanation needed Rustom Mody <rustompmody@gmail.com> - 2014-11-23 22:47 -0800
            Re: Comprehension with two variables - explanation needed Dan Stromberg <drsalists@gmail.com> - 2014-11-24 16:42 -0800
        Re: Comprehension with two variables - explanation needed Skip Montanaro <skip.montanaro@gmail.com> - 2014-11-23 10:45 -0600
        Re: Comprehension with two variables - explanation needed Roy Smith <roy@panix.com> - 2014-11-23 12:08 -0500
        Re: Comprehension with two variables - explanation needed Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2014-11-23 17:46 +0000

csiph-web