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: 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; '>': 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: <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 To: Ivan Evstegneev Content-Type: multipart/alternative; boundary=20cf302efa2854a3a10508889209 Cc: Python , Rustom Mody 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: 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 --20cf302efa2854a3a10508889209 Content-Type: text/plain; charset=UTF-8 > 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 --20cf302efa2854a3a10508889209 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

> 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 understandin= g 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

--20cf302efa2854a3a10508889209--