How can I test if a reference is null ?

Erik Max Francis max at
Fri Mar 28 01:34:18 CET 2003

"Greg Ewing (using" wrote:

> Just as an aside, there isn't really a true equivalent
> of NULL in Python -- all references always point at
> *some* object. None happens to be a built-in object
> provided for references to point at when they don't
> want to point to anything else.

True, although this brings into the semantic question of what NULL in
context really means.  Usually, even in languages with true pointers, it
is used to mean, "This pointer does not point to a valid object," if the
pointer has type T * where T is some object type.  In that case, the
logical Python equivalent is None, which although a unique object, is a
special object intended to indicate, "I'm a special object representing
the lack of a valid object."

So it's true that None and NULL are not truly equivalent, but for the
purposes of the logical, rather than physical meaning, they often are
effectively equivalent.

 Erik Max Francis / max at /
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Who, my friend, can scale Heaven?
\__/ _The Epic of Gilgamesh_
    Alcyone Systems /
 Alcyone Systems, San Jose, California.

More information about the Python-list mailing list