[Python-ideas] Make "is" checks on non-singleton literals errors
Arnaud Delobelle
arnodel at gmail.com
Tue Oct 9 23:50:29 CEST 2012
On 9 October 2012 22:10, Serhiy Storchaka <storchaka at gmail.com> wrote:
> On 09.10.12 23:15, Georg Brandl wrote:
>>
>> The point is that in 99.9...% of cases,
>>
>> if x == True:
>>
>> is just
>>
>> if x:
>
>
> Of cause. However in Lib/unittest/main.py I found a lot of "if x != False:"
> which is not equivalent to just "if x:". It is equivalent to "if x is None
> or x:" and so I left it as is.
???
>>> x = ''
>>> bool(x != False)
True
>>> bool(x is None or x)
False
(same with any empty sequence)
--
Arnaud
More information about the Python-ideas
mailing list