On 14 March 2012 20:37, Croepha <croe...@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
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to