[Python-ideas] Make "is" checks on non-singleton literals errors

Barry Warsaw barry at python.org
Tue Oct 9 17:15:29 CEST 2012


On Oct 08, 2012, at 06:13 PM, Raymond Hettinger wrote:

>
>On Oct 8, 2012, at 12:44 PM, Mike Graham <mikegraham-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org> wrote:
>
>> I regularly see learners using "is" to check for string equality and
>> sometimes other equality. Due to optimizations, they often come away
>> thinking it worked for them.
>> 
>> There are no cases where
>> 
>>    if x is "foo":
>> 
>> or
>> 
>>   if x is 4:
>> 
>> is actually the code someone intended to write.
>> 
>> Although this has no benefit to anyone but new learners, it also
>> doesn't really do any harm.
>
>This seems like a job for pyflakes, pylint, or pychecker.

+1

-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20121009/22fe0846/attachment.pgp>


More information about the Python-ideas mailing list