Checking whether type is None

Chris Angelico rosuav at
Wed Jul 25 17:53:53 EDT 2018

On Thu, Jul 26, 2018 at 2:14 AM, Schachner, Joseph
<Joseph.Schachner at> wrote:
> While I appreciate that use of "is" in   thing is None, I claim this relies on knowledge of how Python works internally, to know that every None actually is the same ID (the same object) - it is singular.

That's part of the *definition* of None. It is a singleton. There is
only one None.

> That probably works for 0 and 1 also but you probably wouldn't consider testing   thing is 1, at least I hope you wouldn't.  thing is None looks just as odd to me.  Why not thing == None ?  That works.

That's not guaranteed, because integers are not guaranteed to be
singletons. They're compared by value.


More information about the Python-list mailing list