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

Guido van Rossum guido at python.org
Tue Oct 9 01:02:27 CEST 2012


On Mon, Oct 8, 2012 at 3:42 PM, Serhiy Storchaka <storchaka at gmail.com> wrote:
> On 08.10.12 22:44, Mike Graham wrote:
>>
>> There are no cases where
>>
>>      if x is "foo":
>
> I see such code in docutils (Doc/tools/docutils/writers/latex2e/__init__.py)

And that's probably a bug.

>> or
>>
>>     if x is 4:
>
> and in tests (Lib/test/test_long.py, Lib/test/test_int.py,
> Lib/test/test_grammar.py, Lib/test/test_winsound.py).

The tests are easily rewritten using

four = 4
if x is four:
  ...

-- 
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list