|
Data Structures and Algorithms
with Object-Oriented Design Patterns in Python |
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 = NoneAlso, we can test explicitly whether a name refers to None like this:
if f is None:
# ...