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
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
> > 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
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
> >> 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
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
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
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