Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: pythonic way (http://www.velocityreviews.com/forums/t954130-re-pythonic-way.html)

jack 11-02-2012 07:14 AM

Re: pythonic way
 
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.




All times are GMT. The time now is 05:05 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.