Next / Previous / Contents / TCC Help System / NM Tech homepage

18. None: The special placeholder value

Python has a unique value called None. This special null value can be used as a placeholder, or to signify that some value is unknown.

In conversational mode, any expression that evaluates to None is not printed. However, if a value of None is converted to a string, the result is the string 'None'; this may happen, for example, in a print statement.

>>> x = None
>>> x
>>> print x
None

The value None is returned from any function that executes a return statement with no value, or any function after it executes its last line if that last line is not a return statement.

>>> def useless():
...     print "Useless!"
... 
>>> useless()
Useless!
>>> z=useless()
Useless!
>>> z
>>> print z
None
>>> def boatAnchor():
...     pass
... 
>>> x=boatAnchor()
>>> x
>>> print x
None