Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '"if': 0.09; 'received:internal': 0.09; 'jan': 0.12; 'posted': 0.15; 'loop.': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:10.202.2.212': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:66.111.4.27': 0.16; 'received:messagingengine.com': 0.16; 'received:out3-smtp.messagingengine.com': 0.16; 'says...': 0.16; 'silly': 0.16; 'statement.': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'code,': 0.22; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'chris': 0.29; 'originally': 0.30; 'easier': 0.31; 'this.': 0.32; 'received:66': 0.35; 'subject:?': 0.36; 'received:10': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'though,': 0.39; 'to:addr:python.org': 0.39; 'from:no real name:2**0': 0.61; 'header:Message-Id:1': 0.63; 'subject:more': 0.64; 'taking': 0.65; 'subject:there': 0.68; 'article': 0.77; 'subject:this': 0.83; "it'd": 0.84 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= message-id:x-sasl-enc:from:to:mime-version :content-transfer-encoding:content-type:subject:date:in-reply-to :references; s=mesmtp; bh=nx9fmCG2V72hxuWAK1hUoVU6Oe8=; b=fTUVfd dO8EO3Ltlzi5sWYVD9z6pMDKWo5ebvPEbnaMs2xDgozh8icutdZCkdQpnqMoR1Gi jSal9A8rHvIdg5ywcqgPRgPgkxAi+M3etX2Yvz7fikeAMrb41ymvfJFgUXWC/2Ph s4sK49rko5X6ITzJUcKc2apPPJP2FceE/NzuI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:x-sasl-enc:from:to :mime-version:content-transfer-encoding:content-type:subject :date:in-reply-to:references; s=smtpout; bh=nx9fmCG2V72hxuWAK1hU oVU6Oe8=; b=fUkpYdhU3sBDM8O+1r9+0q31bSbSvwNK2ec2h6qJziDymSFUh3rU aGSnmqSsTgYtkQehjA5ahRAMsZiTdermJvpwqb5BL3x1Z5dykIPIs+SjrRCg5AVL egkoY+o0/4b0g7kfO+kjc1XLb1Ctmfulr8MK5tETx4F3lXTPR5nriVk= X-Sasl-Enc: XzfFrXMEU2VDfguQ86V7tyl1wsZN24KfcvYV0IwDUKSw 1422382419 From: random832@fastmail.us To: python-list@python.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-46f3f2c7 Subject: Re: Is there a more elegant way to spell this? Date: Tue, 27 Jan 2015 13:13:39 -0500 In-Reply-To: References: 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: 1422382422 news.xs4all.nl 2936 [2001:888:2000:d::a6]:41117 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:84661 On Tue, Jan 27, 2015, at 13:05, Mario Figueiredo wrote: > In article , > jpiitula@ling.helsinki.fi says... > > > > If you mean literally some_predicate, then perhaps this. > > > > if some_predicate: > > for x in seq: > > handle(x) > > > > Careful. See Chris Warrick answer for the correct position of the 'if' > statement. I think by "if you mean literally some_predicate" he was taking some_predicate as a variable [rather than an expression] that does not change during the loop. That'd be a silly thing to do in the originally posted code, though, since it'd be easier to do "[] if not some_predicate else [...]"