Path: csiph.com!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.038 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'alter': 0.09; "(it's": 0.16; 'branch:': 0.16; 'parentheses:': 0.16; 'pythonic': 0.16; 'readable': 0.16; 'traverse': 0.16; 'wrote:': 0.17; 'element': 0.17; 'stick': 0.22; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; '???': 0.27; 'colon': 0.29; 'zero': 0.33; 'to:addr :python-list': 0.33; 'everyone': 0.33; 'list': 0.35; 'said,': 0.35; 'received:192.168.0': 0.35; 'something': 0.35; 'really': 0.36; 'but': 0.36; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'most': 0.61; 'more': 0.63; 'instantly': 0.93 X-Originating-IP: [121.229.152.88] X-EIP: [uU+dIDJ94YvFFNzFPQ/Cdz9Yid9LSrw9] X-Originating-Email: [naruto0.1@live.cn] Date: Fri, 2 Nov 2012 15:14:32 +0800 From: jack User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: pythonic way References: In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable X-OriginalArrivalTime: 02 Nov 2012 07:14:21.0091 (UTC) FILETIME=[AE01E730:01CDB8C9] X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351840531 news.xs4all.nl 6870 [2001:888:2000:d::a6]:34265 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32592 Sometimes=2C I need to alter the element as traverse a list like this=20 (it's a sample): c =3D range(10) i =3D 0 for ele in c: # do something # branch: c[i] =3D # value i +=3D 1 How to be pythonic=EF=BC=9F 2012/11/2 0:54=2C Zero Piraeus : > : > > On 1 November 2012 11:32=2C inshu chauhan wrote: >> what is the most pythonic way to do this : >> >> if 0 < ix < 10 and 0 < iy < 10 ??? > As everyone else has said=2C 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.