None is Python’s singleton object for an empty or absent value. It serves as a placeholder when meaningful data has not yet been calculated, and all references to it point to the same object. section 4.8
Use None in several common situations:
- Treat None as false in a Boolean context, alongside zero and empty values; other nonempty, nonzero values are true. section 3.4.1 section 8.11.1
- Expect a function to return None when it reaches no explicit return statement. An explicit return value is returned instead. section 9.1 section 3.4.6
- Use None as a placeholder for data that is missing, not yet calculated, or invalid. section 4.8 section 14.2.9
Implicit return and invalid input
A function with no return statement produces None. In spreadsheet-style evaluation, cell_value("bad") can also return None to represent a nonnumeric, nonempty string; safe_apply can return None when evaluating a formula raises TypeError. section 9.1 section 14.2.9
def cell_value(string):
try:
return float(string)
except ValueError:
if string == "":
return 0
else:
return None
Shows a compact conversion function that returns zero for blank input and None for invalid nonnumeric input. section 14.2.9
def safe_apply(function, x, y, spreadsheet):
try:
return function(x, y, spreadsheet)
except TypeError:
return None
Shows a wrapper that converts a TypeError during formula evaluation into None. section 14.2.9



