Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32592 > unrolled thread
| Started by | jack <naruto0.1@live.cn> |
|---|---|
| First post | 2012-11-02 15:14 +0800 |
| Last post | 2012-11-02 15:14 +0800 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: pythonic way jack <naruto0.1@live.cn> - 2012-11-02 15:14 +0800
| From | jack <naruto0.1@live.cn> |
|---|---|
| Date | 2012-11-02 15:14 +0800 |
| Subject | Re: pythonic way |
| Message-ID | <mailman.3176.1351840531.27098.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web