Data Structures and Algorithms with Object-Oriented Design Patterns in Python
next up previous index

The Object Named None

In Python, a name always refers to an object. However, sometimes it is convenient to use a name to refer to ``nothing''. Python provides a special type of object for this purpose called NoneType. There is only ever one object of type NoneType and the name of that object is None.

We can explicitly assign a name to None like this:

f = None
Also, we can test explicitly whether a name refers to None like this:
if f is None:
    # ...


next up previous index

Bruno Copyright © 2003, 2004 by Bruno R. Preiss, P.Eng. All rights reserved.