Working With None in Python
Contents
The following are the learnings from the tutorial on None
:
- False friends - words look similar but are completely different
None
andNull
are different- You cannot create
None
variable - equality operator is different from identity operator
- There is only ONE
None
in Python. All variables are pointing to the sameNone
None
is an object, constant and a singleton- check for
None
is done viais
operator - You can use
None
as a default parameter when using mutable data types such as list and dictionary None
appears in the traceback. Follow it to the object that gave the error and see why the object is None when it shouldn’t beNone
is the return value of a function that do not have a return value. Exampleprint
function