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


Groups > comp.lang.python > #32592

Re: pythonic way

Date 2012-11-02 15:14 +0800
From jack <naruto0.1@live.cn>
Subject Re: pythonic way
References <CAFqGZREfq7fO4Okf1Oj9HBeUkWLYK_9=ho8N47_kyTKudGZSFA@mail.gmail.com> <CANaSqUfRdHoeUzcmAsmaK2WBgbXH63ZDu0pg2ebEX8APKkNwaw@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3176.1351840531.27098.python-list@python.org> (permalink)

Show all headers | View raw


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?

  2012/11/2 0:54, Zero Piraeus :
> :
>
> On 1 November 2012 11:32, inshu chauhan <insideshoes@gmail.com> wrote:
>>   what is the most pythonic way to do this :
>>
>>                     if 0 < ix < 10 and 0 < iy < 10 ???
> As everyone else has said, it's perfectly pythonic once you stick the
> colon on the end. You might find it more instantly readable with some
> extra parentheses:
>
>      if (0 < ix < 10) and (0 < iy < 10):
>          # do something
>
> ... but that's really just down to taste.
>
>   -[]z.

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


Thread

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

csiph-web