Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed5.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.021 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'subject:when': 0.07; 'executes': 0.09; 'received:209.85.214.174': 0.13; 'else"': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.21; 'header:In- Reply-To:1': 0.22; 'clause': 0.23; 'cc:2**0': 0.26; 'message- id:@mail.gmail.com': 0.29; 'cc:addr:python.org': 0.29; 'construct': 0.30; 'break': 0.32; 'loop': 0.34; 'steven': 0.34; 'rather': 0.34; 'subject:/': 0.34; 'received:209.85.214': 0.36; 'but': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'useful': 0.38; 'think': 0.38; 'should': 0.38; 'received:209': 0.39; 'header:Received:6': 0.61; 'stop': 0.61; '"for': 0.67 Received-SPF: pass (google.com: domain of arnodel@gmail.com designates 10.182.8.69 as permitted sender) client-ip=10.182.8.69; Authentication-Results: mr.google.com; spf=pass (google.com: domain of arnodel@gmail.com designates 10.182.8.69 as permitted sender) smtp.mail=arnodel@gmail.com; dkim=pass header.i=arnodel@gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=ibkTIs1DQn5LNdH3ySNTi+hAHsdMO0Vh/QUYvnMcl9A=; b=xjs3Tjf4QX+yJhxdEw03YOK6leIe9DkoYOw+tJbZx/Zz4kYsbP2K4FfhcoWFHMya9K 4MLaOgKpGiOSY6SqjlU/+ZvPVzUpmz+77JknwwLcmyDW3BZuGPPeTk/RJ4NHfcgA1X5J cC6teKengfor5poI+DE0wlo84m7ViIT3joWKU= MIME-Version: 1.0 In-Reply-To: <4f47a49e$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <51a08251-1e6e-45f3-8531-b53e87b7db8b@r1g2000yqk.googlegroups.com> <4f47a49e$0$29989$c3e8da3$5496439d@news.astraweb.com> Date: Fri, 24 Feb 2012 15:00:16 +0000 Subject: Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty From: Arnaud Delobelle To: "Steven D'Aprano" Content-Type: text/plain; charset=UTF-8 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 12 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1330095619 news.xs4all.nl 6851 [2001:888:2000:d::a6]:32980 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20816 On 24 February 2012 14:54, Steven D'Aprano wrote: > for...else is a very useful construct, but the name is misleading. It > took me a long time to stop thinking that the else clause executes when > the for loop was empty. This is why I think we should call this construct "for / break / else" rather than "for / else". -- Arnaud