Re: Style question (Poll)

2012-03-15 Thread Jon Clements
On Wednesday, 14 March 2012 21:16:05 UTC, Terry Reedy wrote: > On 3/14/2012 4:49 PM, Arnaud Delobelle wrote: > > On 14 March 2012 20:37, Croepha wrote: > >> Which is preferred: > >> > >> for value in list: > >> if not value is another_value: > >> value.do_something() > >> break > > Do

Re: Style question (Poll)

2012-03-14 Thread Chris Angelico
On Thu, Mar 15, 2012 at 7:37 AM, Croepha 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() > > Comments are welcome, Thanks General principle

RE: Style question (Poll)

2012-03-14 Thread Prasad, Ramit
> > Only use 'is' if you are looking for objects like True, > > False, None or something that MUST be exactly the same object. > > I've rarely seen valid uses of 'is True' or 'is False'. It can be useful when you think something might be None or False. Although, I suppose you could always just us

Re: Style question (Poll)

2012-03-14 Thread Arnaud Delobelle
On 14 March 2012 22:15, Prasad, Ramit wrote: > Only use 'is' if you are looking for objects like True, > False, None or something that MUST be exactly the same object. I've rarely seen valid uses of 'is True' or 'is False'. -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list

RE: Style question (Poll)

2012-03-14 Thread Prasad, Ramit
> >> Which is preferred: > >> > >> for value in list: > >> if not value is another_value: > >> value.do_something() > >> break > > Do you really mean 'is' or '=='? Let me expound on how 'is' and '==' are very different. It may work for some comparisons but often not for others. Certain

Re: Style question (Poll)

2012-03-14 Thread Terry Reedy
On 3/14/2012 4:49 PM, Arnaud Delobelle wrote: On 14 March 2012 20:37, Croepha wrote: Which is preferred: for value in list: if not value is another_value: value.do_something() break Do you really mean 'is' or '=='? If you mean x is not y, write it that way. 'not x is y' can be mis

Re: Style question (Poll)

2012-03-14 Thread Arnaud Delobelle
On 14 March 2012 20:37, Croepha 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 suspe

Style question (Poll)

2012-03-14 Thread Croepha
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() Comments are welcome, Thanks -- http://mail.python.org/mailman/listinfo/python-list