None in Python

Python Methods and Functions

A constant representing the absence of a value.

This constant is the only value for the type NoneType .

None is usually used to indicate that that there is no specific meaning. 
For example, to designate a default parameter of a function.

  # Can't assign a value 
None = 10 # SyntaxError: can't assign to keyword

# Use as default parameter value.
def print_some (value = None):
# If no value is passed, use some.
value = value or 'some'
print (value)

print_some () # some

# Checks for None
# are done with is, not ==
if something is None:
pass

if something is not None:
pass






Tutorials