On Sun, Feb 25, 2024 at 11:29:51AM -0800, Collin Funk wrote:
> On 2/25/24 3:57 AM, Bruno Haible wrote:
> > The style warnings about "!= None" in pycodestyle and/or pylint are
> > relativized by this warning in Python itself:
> > 
> >   >>> '' != None
> >   True
> >   >>> '' is not None
> >   <stdin>:1: SyntaxWarning: "is not" with a literal. Did you mean "!="?
> >   True
> 
> Interesting. I'm not too picky about the convention that we use. 

Just in case: this warning comes from the types of '' and None being different.

>>> 1.0 is 1
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
False

One can compare objects of different types for equality:
>>> type(1.0)
<class 'float'>
>>> type(1)
<class 'int'>
>>> 1.0 == 1
True

(it's the same with "is not" vs. "!=")

Best,
Dima

Attachment: signature.asc
Description: PGP signature

Reply via email to