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

Mike Graham mikegraham at gmail.com
Mon Oct 8 21:44:54 CEST 2012


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.

Mike



More information about the Python-ideas mailing list