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
NoneandNullare different- You cannot create
Nonevariable - equality operator is different from identity operator
- There is only ONE
Nonein Python. All variables are pointing to the sameNone Noneis an object, constant and a singleton- check for
Noneis done viaisoperator - You can use
Noneas a default parameter when using mutable data types such as list and dictionary Noneappears in the traceback. Follow it to the object that gave the error and see why the object is None when it shouldn’t beNoneis the return value of a function that do not have a return value. Exampleprintfunction