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.028 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'subject:Python': 0.06; 'i++)': 0.09; 'subject:language': 0.09; 'cc:addr:python-list': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'imo.': 0.16; 'rewriting': 0.16; 'subject:programming': 0.16; 'variable.': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'subject:/': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'agreed.': 0.31; 'piece': 0.31; 'quite': 0.32; 'fri,': 0.33; 'received:google.com': 0.35; 'c++': 0.36; 'recent': 0.39; 'improved': 0.60; 'such': 0.63; 'more': 0.64; '20,': 0.68; 'improvement': 0.84; 'to:none': 0.92; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=skZaWESfEm6o7HqVWSR8PZPsU032ljaCD6gqL5epY2M=; b=JWFGbSXTeVLNccMWrV5sy2XMBJOZfI1XY+UF1WtO0D0EhuNHjIz5nIgqSbAFaKEyLf NJyvBQnKBXNAsmkr2mKGvU9KJi9LVsazuWwl7bDVKMO9eOiJ0aJHenOQeUf2htQuTwg6 Y1PVQXksvixhGtjqYwSoVU/KG5AqiPu+yDFr0XSEm9mc1tkBGMys6Mres5PZETf1UjSy FVl2zBcX7YcNfVGzU5FMbIuanxHdGdsjrCmmcqTiq7Uq5K5dNTF+LOK4RUXVI8dLMkFS F1LsuL2NUDIaYe+FFhansbk5MGbl0f6QrWmAx7JeZn/Ge0awWq4358nnuNhVqfBu5aJC vF/g== MIME-Version: 1.0 X-Received: by 10.68.212.163 with SMTP id nl3mr4081521pbc.25.1387486276646; Thu, 19 Dec 2013 12:51:16 -0800 (PST) In-Reply-To: References: <20131212213602.806ef8fd2626ca6f34bc83d6@gmx.net> <20131216213225.2006b30246e3a08ee241a191@gmx.net> <20131217162233.1538587c27b6a27df9a33aee@gmx.net> <20131219161413.b011741a67dba9eb892dd500@gmx.net> Date: Fri, 20 Dec 2013 07:51:16 +1100 Subject: Re: Experiences/guidance on teaching Python as a first programming language From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 1387486280 news.xs4all.nl 2855 [2001:888:2000:d::a6]:60683 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:62416 On Fri, Dec 20, 2013 at 7:42 AM, Gregory Ewing wrote: > A piece of code such as > > for (i = 0; i < numThings; i++) > total[i] += things[i]; > > is NOT improved by rewriting it as > > for (theLoopIndex = 0; theLoopIndex < numThings; theLoopIndex++) > total[theLoopIndex] += things[theLoopIndex]; > > Quite the reverse, IMO. Wholeheartedly agreed. The only improvement I would make would be to declare i in the if block (valid in C++ and some of the more recent C standards), to emphasize the locality of the variable. ChrisA