Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: cl@isbd.net Newsgroups: comp.lang.python Subject: Re: Extension of while syntax Date: Fri, 12 Dec 2014 09:09:14 +0000 Lines: 21 Message-ID: References: <14d2b880-3837-4267-a769-33ae7393f78b@googlegroups.com> <87r3w5gx7s.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net YsXuTgjIsPm+gqA+y086FQ+S1rRFMcPWGIkSbDRy6QDwUjt4U= X-Orig-Path: not-for-mail Cancel-Lock: sha1:EzOdP3EAPatAv5qGWWIBw+fWLrU= User-Agent: tin/2.2.0-20131224 ("Lochindaal") (UNIX) (Linux/3.13.0-40-generic (x86_64)) Xref: csiph.com comp.lang.python:82430 Marko Rauhamaa wrote: > Chris Angelico : > > > You could deduplicate it by shifting the condition: > > > > while True: > > value = get_some_value() > > if value not in undesired_values: break > > > > But I'm not sure how common this idiom actually is. > > Extremely common, and not only in Python. > It's the classic C 'for' loop. 'for' in C is essentially a while with an initialiser for the loop variable. -- Chris Green ยท