Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed3.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'iterate': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'shame': 0.09; 'expression,': 0.16; 'finney': 0.16; 'grep': 0.16; 'loops': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:python': 0.16; 'header:User-Agent:1': 0.23; 'exists': 0.24; 'header:X-Complaints-To:1': 0.27; 'perl': 0.31; 'subject:end': 0.31; 'writes:': 0.31; 'regular': 0.32; 'but': 0.35; 'sequence': 0.36; 'possible': 0.36; 'ben': 0.38; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'new': 0.61; 'du,': 0.84; 'sometimes.': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: Re: semicolon at end of python's statements Date: Fri, 30 Aug 2013 08:17:51 +1000 References: <1377735506.18906.15.camel@debian> <1FETt.52607$Mw4.14965@fx15.am4> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: rasputin.madmonks.org X-Public-Key-ID: 0xBD41714B X-Public-Key-Fingerprint: 9CFE 12B0 791A 4267 887F 520C B7AC 2E51 BD41 714B X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-gpg.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:7yh2Y1Zy8AOXsi2z/cNbJk2rYqQ= 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1377814687 news.xs4all.nl 15970 [2001:888:2000:d::a6]:49700 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:53261 Fábio Santos writes: > It is a shame that this is not possible in python. for..if exists in > comprehensions and not in regular loops but that would be nice > sometimes. So you use it in a generator expression, and iterate over the generator: for foo in (spam for spam in sequence if predicate(spam)): process(spam) That way, there's no need for new syntax. -- \ “bash awk grep perl sed, df du, du-du du-du, vi troff su fsck | `\ rm * halt LART LART LART!” —The Swedish BOFH, | _o__) alt.sysadmin.recovery | Ben Finney