Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.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.018 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'skip:[ 20': 0.03; 'python': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'read.': 0.13; '-tkc': 0.16; 'brackets.': 0.16; 'fancy': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'wrote:': 0.17; 'skip:{ 20': 0.17; 'typing': 0.17; 'tim': 0.18; 'url:edu': 0.18; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.28; 'chase': 0.29; 'index,': 0.29; 'value)': 0.29; 'wasting': 0.29; 'this.': 0.29; 'maybe': 0.29; 'from:addr:yahoo.co.uk': 0.32; 'print': 0.32; 'impression': 0.33; 'to:addr:python-list': 0.33; 'list': 0.35; 'doing': 0.35; 'received:org': 0.36; 'but': 0.36; 'rather': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'link': 0.60; 'first': 0.61; 'time,': 0.62; 'more': 0.63; 'our': 0.65; 'harder': 0.65; 'unnecessary': 0.65; 'money': 0.74; 'subject:For': 0.75; 'alec': 0.84; 'ugly,': 0.84; 'received:2': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: For Counter Variable Date: Mon, 24 Sep 2012 02:03:15 +0100 References: <10965867-a44f-4146-aea2-fd1a1e8f8e3b@googlegroups.com> <505f9311$0$1612$c3e8da3$76491128@news.astraweb.com> <505F9B59.6040909@tim.thechases.com> <505FA3C3.8050408@tim.thechases.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-2-97-77-28.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 In-Reply-To: <505FA3C3.8050408@tim.thechases.com> X-Antivirus: avast! (VPS 120923-1, 23/09/2012), Outbound message X-Antivirus-Status: Clean 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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1348448592 news.xs4all.nl 6857 [2001:888:2000:d::a6]:42042 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29879 On 24/09/2012 01:05, Tim Chase wrote: > On 09/23/12 18:52, Alec Taylor wrote: >> You can always use a counter if you don't like our fancy for-each loops; >> >> foolist = [1,24,24,234,23,423,4] >> for i in xrange(len(foolist)): >> print foolist[i] > > http://www.seas.upenn.edu/~lignos/py_antipatterns.html > > The first one on the list of anti-patterns is doing exactly this. > Just don't. Ewww. Inefficient, ugly, and harder to read. > > Part of learning to write in Python is, well, learning to write > *Python*, not {C,C++,Java,PHP}-in-Python. > > -tkc > Maybe my mind is rather more warped than I thought it was, but my first impression was that foolist was a play on foolish. I also like the anti-pattern on the link namely:- for (index, value) in enumerate(alist): print index, value Fancy wasting time, money and effort typing those unnecessary round brackets. -- Cheers. Mark Lawrence.