Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:both': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; '0):': 0.16; 'nay': 0.16; 'range(0,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'wrote:': 0.18; 'version.': 0.19; 'written': 0.21; 'header:User-Agent:1': 0.23; 'header:X -Complaints-To:1': 0.27; 'statement': 0.30; 'run': 0.32; 'but': 0.35; 'there': 0.35; 'subject:one': 0.36; 'charset:us-ascii': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'times': 0.62; 'dont': 0.67; 'canonical': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re: Having both if() and for() statements in one liner Date: Tue, 17 Sep 2013 18:54:51 +0000 (UTC) References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 174.32.174.35 User-Agent: XPN/1.2.6 (Street Spirit ; Linux) 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: 1379444117 news.xs4all.nl 15890 [2001:888:2000:d::a6]:56253 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:54327 On 17/9/2013 09:21, Ferrous Cranus wrote: > I just want to say tot he program that > > that only run the for statement if and only if person=='George' > > I dont see nay reason as to why this fails > > perhaps like: > > for times in range(0, 5) if person=='George': > > but that fails too... > there must be written on soem way. > > untested: for times in range(0, 5 if person=="George" else 0): But i also greately prefer the canonical version. -- DaveA