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


Groups > comp.lang.python > #21624 > unrolled thread

Re: Style question (Poll)

Started byArnaud Delobelle <arnodel@gmail.com>
First post2012-03-14 20:49 +0000
Last post2012-03-14 20:49 +0000
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.


Contents

  Re: Style question (Poll) Arnaud Delobelle <arnodel@gmail.com> - 2012-03-14 20:49 +0000

#21624 — Re: Style question (Poll)

FromArnaud Delobelle <arnodel@gmail.com>
Date2012-03-14 20:49 +0000
SubjectRe: Style question (Poll)
Message-ID<mailman.651.1331758144.3037.python-list@python.org>
On 14 March 2012 20:37, Croepha <croepha@gmail.com> wrote:
> Which is preferred:
>
> for value in list:
>  if not value is another_value:
>    value.do_something()
>    break
>
> --or--
>
> if list and not list[0] is another_value:
>  list[0].do_something()

Hard to say, since they don't do the same thing :)

I suspect you meant:

for value in list:
   if not value is another_value:
       value.do_something()
   break

I always feel uncomfortable with this because it's misleading: a loop
that never loops.

-- 
Arnaud

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web