Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feed.xsnews.nl!border-2.ams.xsnews.nl!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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'list?': 0.07; 'alter': 0.09; 'english,': 0.09; 'cc:addr:python-list': 0.10; "(it's": 0.16; 'branch:': 0.16; 'traverse': 0.16; 'wrote:': 0.17; 'element': 0.17; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'chris': 0.28; "i'm": 0.29; 'fri,': 0.30; 'operate': 0.32; 'function.': 0.33; 'list': 0.35; 'nov': 0.35; 'pm,': 0.35; 'received:192.168.0': 0.35; 'something': 0.35; 'subject:: ': 0.38; 'some': 0.38; 'received:192': 0.39; 'received:192.168': 0.40; 'think': 0.40 X-Originating-IP: [121.229.152.88] X-EIP: [vbvsMlWB3YBUpR3hcPM3vwhBU6S6b4YU] X-Originating-Email: [naruto0.1@live.cn] Date: Fri, 2 Nov 2012 16:58:17 +0800 From: jack User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: Chris Angelico Subject: Re: pythonic way References: In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable X-OriginalArrivalTime: 02 Nov 2012 08:57:58.0989 (UTC) FILETIME=[2829D7D0:01CDB8D8] Cc: python-list@python.org 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: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351846748 news.xs4all.nl 6987 [2001:888:2000:d::a6]:40265 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32604 thanks=2Cbut I don't think enumerate() is my want Have some ways to operate the reference of element=2Cnot a copy when I=20 tried to traverse a list? I'm so sorry about my poor English=2C hope you don't mind it. On 2012/11/2 15:56=2C Chris Angelico wrote: > On Fri=2C Nov 2=2C 2012 at 6:14 PM=2C jack wrote: >> Sometimes=2C I need to alter the element as traverse a list like this (i= t's a >> sample): >> c =3D range(10) >> i =3D 0 >> for ele in c: >> # do something >> # branch: >> c[i] =3D # value >> i +=3D 1 >> >> How to be pythonic=EF=BC=9F > Check out the enumerate() function. > > ChrisA