Style question (Poll)

Arnaud Delobelle arnodel at gmail.com
Wed Mar 14 16:49:02 EDT 2012


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



More information about the Python-list mailing list