[Python-ideas] Make "is" checks on non-singleton literals errors
Guido van Rossum
guido at python.org
Tue Oct 9 00:26:57 CEST 2012
On Mon, Oct 8, 2012 at 3:02 PM, Chris Angelico <rosuav at gmail.com> wrote:
> On Tue, Oct 9, 2012 at 6:44 AM, Mike Graham <mikegraham at gmail.com> wrote:
>> There are no cases where
>> if x is "foo":
>> is actually the code someone intended to write.
> Are literals guaranteed to be interned? If so, this code would make
> sense, if the programmer knows that x is itself an interned string.
No, interning is not guaranteed.
> Although I guess a warning wouldn't be a problem there, as they're
> easily ignored/suppressed.
--Guido van Rossum (python.org/~guido)
More information about the Python-ideas