Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: Extension of while syntax Date: Fri, 12 Dec 2014 10:25:47 +0200 Organization: A noiseless patient Spider Lines: 25 Message-ID: <87iohh5l6c.fsf@elektro.pacujo.net> References: <14d2b880-3837-4267-a769-33ae7393f78b@googlegroups.com> <87r3w5gx7s.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="ff5cf27ef3d5b31f034d3b72bdc27a41"; logging-data="27885"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/5UoqKIdFvjEAEdxz2CA48" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:m1RAL2W/0xkC+I5xWZAnsxJhfEk= sha1:uAw+igl2gZlqPmOAbN6fCaLI+iI= Xref: csiph.com comp.lang.python:82424 Chris Angelico : > On Fri, Dec 12, 2014 at 6:10 PM, 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. > > Something like it is certainly common, but to justify dedicated > syntax, the pure form has to be so amazingly common as to merit it. You already showed the perfect dedicated syntax. The variations of the while-True-...-break idiom are limitless. There's little need to "optimize" it further. Marko