Style question (Poll)

Arnaud Delobelle arnodel at
Wed Mar 14 21:49:02 CET 2012

On 14 March 2012 20:37, Croepha <croepha at> 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:

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


More information about the Python-list mailing list