Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #32604

Re: pythonic way

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 <naruto0.1@live.cn>
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 <naruto0.1@live.cn>
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 <rosuav@gmail.com>
Subject Re: pythonic way
References <CAFqGZREfq7fO4Okf1Oj9HBeUkWLYK_9=ho8N47_kyTKudGZSFA@mail.gmail.com> <CANaSqUfRdHoeUzcmAsmaK2WBgbXH63ZDu0pg2ebEX8APKkNwaw@mail.gmail.com> <BLU0-SMTP321F0666E2573FA6807D728F3670@phx.gbl> <CAPTjJmoNBRsK7YfNwEB2311LeA2Lc_oF0ufuhiAWm99pNcFqEA@mail.gmail.com>
In-Reply-To <CAPTjJmoNBRsK7YfNwEB2311LeA2Lc_oF0ufuhiAWm99pNcFqEA@mail.gmail.com>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3186.1351846748.27098.python-list@python.org> (permalink)
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

Show key headers only | View raw


thanks,but I don't think enumerate() is my want
Have some ways to operate the reference of element,not a copy when I 
tried to traverse a list?

I'm so sorry about my poor English, hope you don't mind it.

On 2012/11/2 15:56, Chris Angelico wrote:
> On Fri, Nov 2, 2012 at 6:14 PM, jack <naruto0.1@live.cn> wrote:
>> Sometimes, I need to alter the element as traverse a list like this (it's a
>> sample):
>>      c = range(10)
>>      i = 0
>>      for ele in c:
>>          # do something
>>          # branch:
>>              c[i] = # value
>>          i += 1
>>
>> How to be pythonic?
> Check out the enumerate() function.
>
> ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: pythonic way jack <naruto0.1@live.cn> - 2012-11-02 16:58 +0800

csiph-web