Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #21624
| References | <CANm61jcTZNVJAbkj2ZGJ+X1-mUZOoXsR90VstC4rb8UOo1x8Ug@mail.gmail.com> |
|---|---|
| Date | 2012-03-14 20:49 +0000 |
| Subject | Re: Style question (Poll) |
| From | Arnaud Delobelle <arnodel@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.651.1331758144.3037.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Style question (Poll) Arnaud Delobelle <arnodel@gmail.com> - 2012-03-14 20:49 +0000
csiph-web