Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.023 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'received:209.85.213.174': 0.16; 'received:mail-yx0-f174.google.com': 0.16; 'subject:Poll': 0.16; '\xc2\xa0if': 0.16; 'cc:addr:python-list': 0.16; 'subject:question': 0.16; 'wrote:': 0.18; 'say,': 0.19; 'cc:no real name:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'suspect': 0.24; 'cc:2**0': 0.26; 'message-id:@mail.gmail.com': 0.29; 'cc:addr:python.org': 0.29; 'skip:\xc2 20': 0.30; 'list': 0.32; 'loop': 0.34; 'list:': 0.35; 'received:google.com': 0.37; 'received:209.85': 0.38; 'received:209': 0.39; 'subject: (': 0.40; 'march': 0.61 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=4t6wF/bYKJ2iqWcdZasSA+5n7KGgj3fe82BeE9HoMAM=; b=X86WoFRV4H72fzroNoBz8qnHVvoULuxXgWTR6yOGU8Xzm7Both7HKoap9OsbwLCBBL hnGHTKMpDNDKs/JU8a//j/87ooxKD4AgAIzo4WaTz3hqVi4nrdoYLjfB6wBxV9AuextS TSi3xJXxxtK6Pg8nofRRcEq4dIZ5eZF/skHArIcfdMgJLScdH5dfJd2hJTEspuZXY7ci MZJ6VNwmA5lrH/JFkwB/NV+3MY7pl8aKyt1LH7vEOklNaDKNRWrREFRS3/8zJc5+sp1R LuEqprjpVKxHEeCd1wviQVLsv8tQQaV4H07W/qtrOrgdNb/WGLzT0dRRXV92D9q4sEVV 0mxA== MIME-Version: 1.0 In-Reply-To: References: Date: Wed, 14 Mar 2012 20:49:02 +0000 Subject: Re: Style question (Poll) From: Arnaud Delobelle To: Croepha Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1331758144 news.xs4all.nl 6885 [2001:888:2000:d::a6]:33617 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:21624 On 14 March 2012 20:37, Croepha wrote: > Which is=C2=A0preferred: > > for value in list: > =C2=A0if not value is another_value: > =C2=A0 =C2=A0value.do_something() > =C2=A0 =C2=A0break > > --or-- > > if list and not list[0] is another_value: > =C2=A0list[0].do_something() Hard to say, since they don't do the same thing :) I suspect you meant: for value in list: =C2=A0 if not value is another_value: =C2=A0 =C2=A0 value.do_something() =C2=A0break I always feel uncomfortable with this because it's misleading: a loop that never loops. --=20 Arnaud