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


Groups > comp.lang.python > #32604

Re: pythonic way

Date 2012-11-02 16:58 +0800
From jack <naruto0.1@live.cn>
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>
Newsgroups comp.lang.python
Message-ID <mailman.3186.1351846748.27098.python-list@python.org> (permalink)

Show all headers | 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